/*
TASK:family
LANG:C++
*/
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
bool can(string s1, string s2)
{
 if (s1.size()!=s2.size()) return false; 
 sort(s2.begin(),s2.end());
 for (int i=0;i<s1.size();i++)
 { 
  for (char ch='A';ch<='Z';ch++)
  {
   string temp=s1; temp[i]=ch;
   sort(temp.begin(),temp.end());
   if (temp==s2) return true;
  } 
 }
 return false;
}
int main()
{
 int n,i;
 vector <string> words; cin>>n;
 for (i=0;i<n;i++) { string s; cin>>s; words.push_back(s); }
 bool added[n]; for (i=0;i<n;i++) added[i]=false;
 int ans=0;
 for (i=0;i<n;i++)
 {
  if (added[i]) continue;
  queue <string> comp; comp.push(words[i]);
  int cur=1; added[i]=true; //cout<<words[i]<<" ";
  while (!comp.empty())
  {
   string top=comp.front();
   comp.pop();
   for (int j=0;j<words.size();j++)
    if (!added[j] && can(top,words[j]))
    {
     cur++;
     added[j]=true;
     comp.push(words[j]);
    // cout<<words[j]<<" ";
    }
  }
//  cout<<endl;
  if (cur>ans) ans=cur;
 }
 cout<<ans<<endl;
 return 0;
}
