#include <bits/stdc++.h>
using namespace std;
int n,x[100005],y[100005],brx1,brx2,bry1,bry2,res;
int main () {
    cin>>n;
    res=0;
    for(int i=1;i<=n;i++){
        cin>>x[i]>>y[i];
        if(x[i]==2){brx2++;}
        else if(x[i]==1){brx1++;}
        if(y[i]==2){bry2++;}
        else if(y[i]==1){bry1++;}
    }
    if(brx1==0){res++;}
    if(brx2==0){res++;}
    if(bry1==0){res++;}
    if(bry2==0){res++;}
    cout<<res<<endl;
    return 0;
}