#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> first;
  int* answer = new int[n];
  for (int x = 0; x < n; x++) {
    int num;
    cin >> num;
    first.push_back(num);
  }
  int curr = 0;
  int prev = 0;
  for (int x = 0; x < n; x++) {
    int num;
    cin >> num;
    if (num == first[curr]) {
      curr++;
      prev++;
    }
  }
  cout << n - prev;
  return 0;
}
