#include<iostream>
using namespace std;

int perm1[100001];
int altPerm[100001];

int main() {
	int n, br = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> perm1[i];
		altPerm[perm1[i]] = i;
	}
	int k, pos;
	cin >> k;
	pos = altPerm[k];
	for (int i = 2; i <= n; i++) {
		cin >> k;
		pos++;
		if (k != perm1[pos]) {
			br++;
			pos = altPerm[k];
		}
		
	}
	br++;
	cout << br << endl;
	return 0;
}