#include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 1e5 + 5;
int main() {
  int n, a[maxn], b[maxn];
  while (~scanf("%d", &n)) {
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    int sum = 0, j = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &b[i]);
      if (b[i] == a[j])
        j++;
      else
        sum++;
    }
    printf("%d\n", sum);
  }
}
