#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
const int maxs = 1e3 + 10;
char str[maxs];
int cnt[maxn][30];
int len[maxn];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", str);
    len[i] = strlen(str);
    for (int j = 0; j < len[i]; j++) cnt[i][str[j] - 'a']++;
  }
  int ans1 = 0;
  for (int i = 0; i < 26; i++) {
    int tmp = 0;
    for (int j = 0; j < n; j++) {
      bool ok = 1;
      for (int k = 0; k < 26; k++) {
        if (k != i && cnt[j][k]) {
          ok = 0;
          break;
        }
      }
      if (ok) tmp += len[j];
    }
    ans1 = max(ans1, tmp);
  }
  int ans2 = 0;
  for (int i = 0; i < 26; i++) {
    for (int j = i + 1; j < 26; j++) {
      int tmp = 0;
      for (int k = 0; k < n; k++) {
        bool ok = 1;
        for (int l = 0; l < 26; l++) {
          if ((l != i && l != j) && cnt[k][l]) {
            ok = 0;
            break;
          }
        }
        if (ok) tmp += len[k];
      }
      ans2 = max(ans2, tmp);
    }
  }
  printf("%d\n", max(ans1, ans2));
  return 0;
}
