#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

deque<int> col;



int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    col.push_front(a[0]);
    for (int i = 1; i < n; i++){
        int idx = lower_bound(col.begin(), col.end(), a[i]) - col.begin();
        if(idx == 0){
            col.push_front(a[i]);
        }else{
            col[idx-1] = a[i];
        }
    }
    int ans = col.size();
    cout << ans << endl;
}
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
	int n, m, t, i, j;
	scanf("%d %d", &n, &m);

	vector<int> sports;
	vector<int> votes(m, 0);

	for(i = 0;i < n;++i){
		scanf("%d", &t);
		sports.push_back(t);
	}

	for(i = 0;i < m;++i){
		scanf("%d", &t);
		for(j = 0;j < n;++j){
			if(sports[j] <= t){
				votes[j]++;
				break;
			}
		}
	}

	vector<int>::iterator itr = max_element(votes.begin(), votes.end());
	size_t d = distance(votes.begin(), itr);
	printf("%zu\n", d+1);

	return 0;
}
