#include <bits/stdc++.h>
int n;
int x[200050];
int f[200050];
int ans = 0;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  for (int i = 0; i < n; i++) scanf("%d", &f[i]);
  int k = 0, l = 0;
  while (l < n) {
    if (x[k] == f[l])
      k++, l++;
    else
      ans++, l++;
  }
  printf("%d\n", ans);
}
