#include<bits/stdc++.h>
using namespace std;
main()
{
    int ao,bo,af,bf,t,c=0;
    cin>>t;
    cin>>ao>>bo;
    af=ao;
    bf=bo;
    t--;
    while(t--)
    {
        cin>>ao>>bo;
        if(af!=ao&&bf!=bo)
            c++;
        af=ao;
        bf=bo;
    }
    cout<<c<<endl;
    return 0;
}
