#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  int an = 0;
  for (int i = 0; i < n; i++) {
    if (a[an] == b[i]) {
      an++;
    }
  }
  cout << n - an << endl;
  return 0;
}
