#include<bits/stdc++.h>
using namespace std;
int shu(string a){
	int ans=0;
	for(int i=a.size()-1;i>=0;i--){
		ans+=a[i];
		ans*=36;
	}
	return ans%114514;
}
int f[10000000],s[10000000],t[10000000],fo[10000000];
int main(){
	int n,m1=0,m2=0,m3=0,m4=0;
	string str;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>str;
		f[shu(str)]++;
		m1=max(f[shu(str)],m1);
		cin>>str;
		s[shu(str)]++;
		m2=max(s[shu(str)],m2);
		cin>>str;
		t[shu(str)]++;
		m3=max(t[shu(str)],m3);
		cin>>str;
		fo[shu(str)]++;
		m4=max(fo[shu(str)],m4);
	}
	cout<<min(m1,m4)-1;
	return 0;
}   
/*           
                                                                         OOOOOO          OOOOOO                           
                                                                        O O             O O                   
                                                                       O   O           O   O                  
                                                                      O     O         O     O                 
                                                                                O                          
                                                                                O                                   
                                                                                O                        
                                                                        OOOOOOOOOOOOOOOOOOO                                  
                                                                                O                          
                                                                                O                          
          OOOOOOOOOOOOOOOOOOOOOOOOOOOOO                                         O                          
                                                                 OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                                      
                                                                                O                          
                                                                                O                          
                                                                                O                          
                                                                      OOOOOOOOOOOOOOOOOOOOOOOOO                                    
                                                                                O                          
                                                                             O  O                          
                                                                              O O                          
                                                                               OO                      */