#include <bits/stdc++.h>
int compare(const void *a, const void *b) {
  char x = *(char *)a, y = *(char *)b;
  return x - y;
}
int main() {
  int n;
  int i, j, k, t;
  int pair[26][26] = {0};
  char s[1000];
  char fir, sec;
  int max = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", s);
    qsort(s, strlen(s), sizeof(char), compare);
    t = 0;
    for (j = 0; j < strlen(s); j++) {
      k = j + 1;
      t++;
      if (t == 1)
        fir = s[j];
      else if (t == 2)
        sec = s[j];
      else
        break;
      while (k < strlen(s) && s[k] == s[j]) k++;
      j = k - 1;
    }
    if (t == 1)
      pair[fir - 'a'][fir - 'a'] += strlen(s);
    else if (t == 2) {
      pair[fir - 'a'][sec - 'a'] += strlen(s);
    }
  }
  for (i = 0; i < 26; i++) {
    for (j = i; j < 26; j++) {
      if (i == j)
        max = (max < pair[i][i]) ? pair[i][i] : max;
      else {
        t = pair[i][j] + pair[i][i] + pair[j][j];
        max = (max < t) ? t : max;
      }
    }
  }
  printf("%d\n", max);
}
