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