#include <bits/stdc++.h>
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    int i, j, k, l, num, sum = 0, max = 0;
    char c[105][1005];
    for (i = 0; i < n; i++) {
      scanf("%s", c[i]);
    }
    for (i = 'a'; i <= 'z'; i++) {
      for (j = i; j <= 'z'; j++) {
        sum = 0;
        for (k = 0; k < n; k++) {
          for (l = 0; l < strlen(c[k]); l++) {
            if (c[k][l] != i && c[k][l] != j) break;
          }
          if (l == strlen(c[k])) sum += strlen(c[k]);
        }
        if (max < sum) max = sum;
      }
    }
    printf("%d\n", max);
  }
  return 0;
}
