#include <bits/stdc++.h>
using namespace std;
int a[200001];
int b[200001];
void swap(int &a, int &b) {
  a = a + b;
  b = a - b;
  a = a - b;
}
int main() {
  int n, m1 = 0, m2 = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  int f = 0;
  int i, j;
  for (i = 0, j = 0; i < n; i++) {
    for (; j < n; j++) {
      if (a[i] == b[j]) {
        break;
      }
    }
    if (j == n) break;
  }
  cout << (n - i) << endl;
  return 0;
}
