#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, j = 0, pos = 0, count = 0, x;
  vector<int> v1, v2;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x;
    v1.push_back(x);
  }
  for (i = 0; i < n; i++) {
    cin >> x;
    v2.push_back(x);
  }
  for (i = 0; i < n; i++) {
    for (; j < n; j++) {
      if (v1[i] == v2[j]) {
        j++;
        goto yo;
        break;
      }
    }
    goto end;
  yo:
    continue;
  }
end:
  cout << n - i;
}
