#include <bits/stdc++.h>
using namespace std;
char str[101][1001];
int cnt[101];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> str[i];
    int len = strlen(str[i]), flag[26], c = 0;
    memset(flag, 0, sizeof(flag));
    for (int j = 0; j < len; j++)
      if (!flag[str[i][j] - 'a']) {
        flag[str[i][j] - 'a'] = 1;
        c++;
      }
    cnt[i] = c;
  }
  int ans = 0;
  for (int i = 0; i < 26; i++)
    for (int j = i + 1; j < 26; j++) {
      int aux = 0;
      for (int k = 0; k < n; k++)
        if (cnt[k] < 3) {
          int flag = 0, len = strlen(str[k]);
          for (int l = 0; l < len; l++)
            if (str[k][l] - 'a' != i && str[k][l] - 'a' != j) {
              flag = 1;
              break;
            }
          if (!flag) aux += len;
        }
      ans = max(ans, aux);
    }
  cout << ans << endl;
  return 0;
}
