#include <bits/stdc++.h>
using namespace std;
map<long long, long long> m1;
map<long long, long long> m2;
map<long long, long long> m3;
int main() {
  long long ans = 0, a, b, n, i, j = 0;
  cin >> n;
  map<long long, long long>::iterator it1 = m1.begin();
  map<long long, long long>::iterator it2 = m2.begin();
  for (i = 1; i <= n; i++) {
    cin >> a;
    m1[i] = a;
  }
  for (i = 1; i <= n; i++) {
    cin >> b;
    m2[i] = b;
  }
  it1 = m1.begin();
  it2 = m2.begin();
  while (it1 != m1.end()) {
    if (it1->second == it2->second) {
      it1++;
      it2++;
    } else if (it1->second != it2->second && m3.count(it1->second) != 1) {
      ans++;
      m3[it2->second]++;
      it2++;
    } else if (m3.count(it1->second) == 1)
      it1++;
  }
  cout << ans << endl;
  return 0;
}
