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