#include <bits/stdc++.h>
using namespace std;
const int MaxN = 300005;
int a[MaxN], b[MaxN];
int main() {
  int N;
  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 p1 = 0, p2 = 0;
  while (1) {
    if (p1 >= N || p2 >= N) break;
    if (a[p1] == b[p2])
      p1++, p2++;
    else
      p2++;
  }
  cout << N - p1 << endl;
}
