#include <bits/stdc++.h>
using namespace std;
char s[1003];
int f[1003][300];
int m[1003];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); i++) {
    scanf("%s", s);
    m[i] = strlen(s);
    for (int j = 0; j < (int)(m[i]); j++) {
      f[i][s[j]]++;
    }
  }
  int ans = 0;
  for (int a = 'a'; a <= 'z'; a++) {
    int acc = 0;
    for (int i = 0; i < (int)(n); i++) {
      if (f[i][a] == m[i]) {
        acc += m[i];
      }
    }
    ans = max(ans, acc);
  }
  for (int a = 'a'; a <= 'z'; a++) {
    for (int b = a + 1; b <= 'z'; b++) {
      int acc = 0;
      for (int i = 0; i < (int)(n); i++) {
        if (f[i][a] + f[i][b] == m[i]) {
          acc += m[i];
        }
      }
      ans = max(ans, acc);
    }
  }
  printf("%d\n", ans);
  return 0;
}
