#include <iostream>
using namespace std;

int main()
{
	int a, b, c;
	int i, j, N, pom = 1, pom1 = 1, pom2 = 1;
	
	cin >> N;
	
	int granice[ N - 1 ][ 2 ];
	
	for( i = 0; i < N - 1; ++i )
	{
		cin >> granice[ i ][ 0 ]
			>> granice[ i ][ 1 ];
			
		if( i )
		{
			if( granice[ i ][ 0 ] != granice[ i - 1 ][ 0 ] )
				pom = 0;
			
			if( granice[ i ][ 1 ] != granice[ i - 1 ][ 1 ] )
				pom1 = 0;
				
		}
		
	}
	
	for( i = 1; i < N - 1; ++i )
	{
	  	a = granice[ i ][ 0 ] - granice[ i ][ 1 ];
		b = granice[ i - 1 ][ 0 ] - granice[ i - 1 ][ 1 ];
		
		if( a != b )
			pom2 = 0;
	}
	
	if( pom || pom1 )
		cout << 2;
	else if( pom2 )
		cout << 1;
	else
		cout << 4;
	
	
	return 0;
}