#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  solve();
  return 0;
}
int a[200500], b[200500];
void solve() {
  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 now = 0;
  int kol = 0;
  for (int i = 0; i < n; i++) {
    while (now < n && b[now] != a[i]) now++;
    if (now == n) break;
    if (b[now] == a[i]) kol++;
  }
  cout << n - kol;
}
