#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 1;
void solve() {
  long long int n, m, k, p = 0, q = 0, s = 0, c = 0, i, j;
  cin >> n;
  long long int a[n + 1], b[n + 1];
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  for (long long int i = 1; i <= n; i++) cin >> b[i];
  j = 1;
  for (long long int i = 1; i <= n; i++)
    if (a[j] == b[i]) s++, j++;
  cout << n - s;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
