#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[101][1001];
  int n, ans = 0, c, le, ar[100];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 'a'; i <= 'z'; ++i)
    for (int j = 'a'; j <= 'z'; ++j) {
      le = 0;
      for (int k = 0; k < n; k++) {
        c = 1;
        for (int l = 0; s[k][l] != 0; l++) {
          if (s[k][l] != i && s[k][l] != j) {
            c = 0;
          }
        }
        if (c == 1) {
          le = le + strlen(s[k]);
        }
      }
      ans = max(ans, le);
    }
  cout << ans << endl;
}
