#include <bits/stdc++.h>
using namespace std;
int n, a[201000], b[201000];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  for (int i = 0; i < n; ++i) scanf("%d", &b[i]);
  int x = 0, y = 0;
  while (y < n)
    if (a[x] == b[y])
      ++x, ++y;
    else
      ++y;
  cout << n - x << endl;
  return 0;
}
