#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
#define maxn 1005
#define inf 0x3f3f3f3f
typedef long long LL;
char s[101][maxn];
int main()
{
int n;
freopen("in.txt", "r", stdin);
while( ~scanf("%d", &n) ){
int sum = 0;
for(int i = 0; i < n; i++){
scanf("%s", s[i]);
}
int res = 0;
for(int i=0;i<26;i++)
for(int j=i+1;j<26;j++){
sum = 0;
for(int k=0;k<n;k++){
int t=0;
while(s[k][t]){
if(s[k][t] != i+'a' && s[k][t] != j+'a'){
t=0;
break;
}
t++;
}
sum += t;
}
res = max(sum, res);
}
printf("%d\n",res);
}
}