#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
int a[MAXN], b[MAXN];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  int a_p = 0, b_p = 0;
  while (b_p < n) {
    if (a[a_p] != b[b_p])
      ++b_p;
    else {
      ++a_p;
      ++b_p;
    }
  }
  cout << n - a_p;
  return 0;
}
