#include <bits/stdc++.h>
using namespace std;
char a[110][1010];
void solve() {
  int n, i, j, k, curr, mx, l, p;
  char c1, c2;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) scanf("%s", &a[i]);
  mx = 0;
  for (i = 0; i < 26; ++i) {
    for (j = i + 1; j < 26; ++j) {
      c1 = (char)('a' + i);
      c2 = (char)('a' + j);
      curr = 0;
      for (k = 0; k < n; ++k) {
        l = strlen(a[k]);
        for (p = 0; p < l; ++p)
          if (a[k][p] != c1 && a[k][p] != c2) break;
        if (p == l) {
          curr += p;
        }
      }
      mx = max(mx, curr);
    }
  }
  printf("%d\n", mx);
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
