#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[200000];
  int n, i, num, ans = 0, pos = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++) {
    scanf("%d", &num);
    if (num == a[pos])
      pos++;
    else
      ans++;
  }
  printf("%d\n", ans);
  return 0;
}
