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