#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int a[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int j = 0;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    if (a[j] == temp) j++;
  }
  cout << n - j << "\n";
}
