#include<bits/stdc++.h>
#define int long long
using namespace std;
ifstream fin("proposal.in");
ofstream fout("proposal.out");
auto mread = [](){int x;fin >> x;return x;};
const int N = 105;
int n = mread(), a[N], b[N];
signed main(){
for(int i = 1; i <= n; i ++)
a[i] = mread();
for(int i = 1; i <= n; i ++)
b[i] = mread();
for(int i = 0; i <= n; i ++){
int e = 1;
for(int j = i + 1; j <= n; j ++){
if(a[j - i] > b[j])
e = 0;
}
if(e){
fout << i;
return 0;
}
}
return 0;
}