#include <bits/stdc++.h>
using namespace std;
void dbvar() { cerr << "]" << endl; }
template <class H, class... T>
void dbvar(H h, T... t) {
  cerr << to_string(h);
  if (sizeof...(t)) cerr << ", ";
  dbvar(t...);
}
const long long int inf = (long long int)1e18;
const int mod = (long long int)1e9 + 7;
const long double eps = (long double)1e-9;
const long double pi = acos(-1.0);
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int d8x[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int d8y[8] = {0, 1, 1, 1, 0, -1, -1, -1};
long long int power(long long int n, long long int m) {
  if (m == 0) return 1;
  long long int val = power(n, m / 2);
  if (m % 2 == 0)
    return (val * val);
  else
    return ((val * val) * n);
}
long long int powermod(long long int n, long long int m, long long int _MOD) {
  if (m == 0) return 1;
  long long int val = powermod(n, m / 2, _MOD);
  val %= _MOD;
  if (m % 2 == 0)
    return (val * val) % _MOD;
  else
    return (((val * val) % _MOD) * n) % _MOD;
}
int mult(long long int a, long long int b) { return (a * b) % 1000000007; }
int pot(int n, int k) {
  if (k == 0) return 1;
  long long int a = pot(n, k / 2);
  a = mult(a, a);
  if (k % 2)
    return mult(a, n);
  else
    return a;
}
int divide(int a, int b) { return mult(a, pot(b, 1000000007 - 2)); }
int sub(int a, int b) {
  if (a - b >= 0) return a - b;
  return a - b + 1000000007;
}
int add(int a, int b) {
  if (a + b >= 1000000007) return a + b - 1000000007;
  return a + b;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (auto &x : a) cin >> x;
  ;
  for (auto &x : b) cin >> x;
  ;
  int ans = 0, idx = 0;
  for (int i = 0; i < n; i++) {
    if (a[idx] == b[i]) ans++, idx++;
  }
  cout << n - ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
