#include<bits/stdc++.h>
using namespace std;
int n, a[100003], b[100003], ans = 0;
int main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)cin >> a[i];
    for(int i = 1; i <= n;){
        if(i == 1)cin >> b[i];
        for(int j = 1; j <= n; j++){
            bool p = false;
            while(a[j] == b[i]){
                p = true;
                //cout << b[i] << " " << j << " " << i << " " << ans << endl;
                i++; j++;
                if(i <= n)cin >> b[i];
            }
            if(p)break;
        }
        ans++;
    }
    cout << ans << endl;


    return 0;
}

