#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
char ch[maxn];
int n;
int cnt[maxn][30];
int len[maxn];
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%s", ch);
      len[i] = strlen(ch);
      memset(cnt[i], 0, sizeof(cnt[i]));
      for (int j = 0; j < len[i]; j++) cnt[i][ch[j] - 'a']++;
    }
    int ans = 0;
    for (int j = 0; j < 26; j++) {
      for (int k = j + 1; k < 26; k++) {
        int tmp = 0;
        for (int i = 0; i < n; i++) {
          if (cnt[i][j] + cnt[i][k] == len[i]) tmp += len[i];
        }
        ans = max(ans, tmp);
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
