#include <bits/stdc++.h>
using namespace std;
char z[123][1234];
int n;
bool y;
int sum;
int ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%s", z[i]);
  for (int i = 1; i <= 26; i++)
    for (int j = 1; j <= 26; j++) {
      ans = 0;
      if (i == j) continue;
      for (int k = 1; k <= n; k++) {
        y = 1;
        for (int l = 0; l < strlen(z[k]); l++) {
          if (z[k][l] != j + 'a' - 1 && z[k][l] != i + 'a' - 1) {
            y = 0;
            break;
          }
        }
        if (y == 1) ans += strlen(z[k]);
        sum = max(sum, ans);
      }
    }
  cout << sum;
  return 0;
}
