#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int st[maxn];
int ed[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &st[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &ed[i]);
  int ans = 0;
  int i, j = 1;
  for (i = 1; i <= n; i++) {
    for (; j <= n; j++) {
      if (st[i] == ed[j]) {
        ans++;
        break;
      }
    }
    if (j > n) break;
  }
  printf("%d\n", n - ans);
  return 0;
}
