#include <bits/stdc++.h>
using namespace std;
const int MAX = 2 * 100000 + 10;
int n, a[MAX];
int main() {
  int i, j, t;
  while (cin >> n) {
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    j = 0;
    for (int i = 0; i < n; i++) {
      cin >> t;
      if (a[j] == t) {
        j++;
      }
    }
    cout << n - j << endl;
  }
  fclose(stdin);
  fclose(stdout);
  return 0;
}
