#include<iostream>
using namespace std;
int main()
{
    int n,z=0,a,b;
    cin>>n;
    int x[n],y[n],iks=0,ips=0;
    for(int i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
        iks=iks+x[i];
        ips=ips+y[i];
    }
    for(int i=1;i<=n;i++)
        z=z+i;
    if(iks==z&&ips==z)
        cout<<"0"<<endl;
    else
    {
        a=iks-z;
        b=ips-z;
        if(a<1)
            a=-a;
        if(b<1)
            b=-b;
        a=a+b;
        cout<<a<<endl;
    }

}