#include #include #include #include using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(int)(n); i++) int main(){ int N; cin >> N; vector A(N); { vector P(N); rep(i,N){ cin >> P[i]; P[i]--; } vector Q(N); rep(i,N){ cin >> Q[i]; Q[i]--; } vector invQ(N); rep(i,N) invQ[Q[i]] = i; rep(i,N) A[i] = invQ[P[i]]; } int K = N; rep(i,N-1) if(A[i] + 1 == A[i+1]) K--; int ans = 0; while((1 << ans) < K) ans++; cout << ans << endl; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;