#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
 
 
const int INF = 1000000;
 

int main(){
	int n, m;
	cin>>n>>m;
	vi v(n, 0);
	vi u(n, 0);
	for(int i = 0; i < n; i++) cin>>v[i];
	int a;
	for(int i = 0; i < m; i++){
		cin>>a;
		for(int i = 0; i < n; i++){
			if(v[i] <= a){
				//cout<<" "<<i;
				u[i]++;
				break;
			}
		}
	}
	//cout<<endl;
	int ans = 0;
	for(int i = 1; i < n; i++){
		if(u[ans] < u[i]) ans = i;
	}
	cout<<ans+1<<endl;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<int> > A(H, vector<int> (W)), B(H, vector<int> (W));
    rep(i,H){
        rep(j,W){
            cin >> A[i][j];
        }
    }
    rep(i,H){
        rep(j,W){
            cin >> B[i][j];
        }
    }
    
    vector<vector<vector<int> > > dp(H, vector<vector<int> >(W, vector<int> (6480)));
    rep(i,H){
        rep(j,W){
            rep(k,6480){
                dp[i][j][k] = 0;
            }
        }
    }
    vector<vector<int> > C(H, vector<int> (W));
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            C[i][j] = abs(A[i][j] - B[i][j]);
        }
    }
    dp[0][0][C[0][0]] = 1;
    for (int i = 0; i < H - 1; i++){
        for (int j = 0; j < W - 1; j++){
            for (int k = 0; k < 6400; k++){
                if (dp[i][j][k] > 0){
                    dp[i][j + 1][abs(k - C[i][j + 1])]++;
                    dp[i][j + 1][abs(k + C[i][j + 1])]++;
                }
            }
        }
        for (int j = 0; j < W; j++){
            for (int k = 0; k < 6400; k++){
                if (dp[i][j][k] > 0){
                    dp[i + 1][j][abs(k - C[i + 1][j])]++;
                    dp[i + 1][j][abs(k + C[i + 1][j])]++;
                }
            }
        }
    }
    for (int j = 0; j < W - 1; j++){
        for (int k = 0; k < 6400; k++){
            if (dp[H - 1][j][k] > 0){
                dp[H - 1][j + 1][abs(k - C[H - 1][j + 1])]++;
                dp[H - 1][j + 1][abs(k + C[H - 1][j + 1])]++;
            }
        }
    }
    int ans = 6479;
    for (int k = 6479; k >= 0; k--){
        if (dp[H - 1][W - 1][k] > 0) ans = k;
    }
    cout << ans << endl;
}
