#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 1e18;
const int N = 1111;
char s[N][N];
int num[N][26];
int len[N];
int n;
int main() {
  while (scanf("%d", &n) != EOF) {
    int i, j, k;
    memset(len, 0, sizeof(len));
    memset(num, 0, sizeof(num));
    for (i = 0; i < n; ++i) {
      scanf("%s", s[i]);
      for (j = 0; s[i][j]; ++j) {
        num[i][s[i][j] - 'a']++;
        len[i]++;
      }
    }
    int ans = 0;
    for (i = 0; i < 26; ++i) {
      for (j = i + 1; j < 26; ++j) {
        int tmp = 0;
        for (k = 0; k < n; ++k) {
          if (num[k][j] + num[k][i] == len[k]) tmp += len[k];
        }
        ans = max(ans, tmp);
      }
    }
    printf("%d\n", ans);
  }
}
