import sys input = sys.stdin.readline N=int(input()) H=list(map(int,input().split())) T=list(map(int,input().split())) X=H+T+[0] X=sorted(set(X)) D={X[i]:i for i in range(len(X))} for i in range(N): H[i]=D[H[i]] T[i]=D[T[i]] DOUBLING=[0]*len(X) for i in range(N): DOUBLING[H[i]]=max(DOUBLING[H[i]],T[i]) for i in range(1,len(X)): DOUBLING[i]=max(DOUBLING[i],DOUBLING[i-1]) DOUBLING=[DOUBLING] for i in range(30): j = 1<=to: if i==0: now=to score+=1 break else: now=DOUBLING[i-1][now] score+=(1<