#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=110;
ll a[N],b[N];
int n,cnt;
int main () {
freopen("proposal.in","r",stdin);
freopen("proposal.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
for (int i=1;i<=n;i++) scanf("%lld",&b[i]);
for (int i=1;i<=n;i++) {
if (i+cnt>n) break;
while (a[i]>b[i+cnt]) cnt++;
}
printf("%d",cnt);
return 0;
}