#include <bits/stdc++.h>
using namespace std;
int n, dem[27], kq;
string a[101];
bool check(string a, char x, char y) {
  char xx = a[0];
  for (int i = 0; i < a.size(); i++)
    if (a[i] != x && a[i] != y) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (char i = 'a'; i <= 'z'; i++)
    for (char j = 'a'; j <= 'z'; j++) {
      int tg = 0;
      for (int k = 1; k <= n; k++)
        if (check(a[k], i, j)) tg += a[k].size();
      if (kq < tg) {
        kq = tg;
      }
    }
  printf("%d", kq);
}
