#include <bits/stdc++.h>
int freq[100][128];
char str[1024];
int cntf(int i) {
  int j;
  int t = 0;
  for (j = 'a'; j <= 'z'; ++j) {
    if (freq[i][j]) {
      t++;
    }
    if (t > 2) {
      break;
    }
  }
  return t;
}
int main() {
  int i, n;
  int mxl = 0;
  int cl = 0;
  char a, b;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    char *t;
    scanf("%s", str);
    t = str;
    while (*t) {
      freq[i][*t]++;
      t++;
    }
  }
  for (a = 'a'; a <= 'z'; a++) {
    for (b = a + 1; b <= 'z'; b++) {
      cl = 0;
      for (i = 0; i < n; i++) {
        int t = cntf(i);
        if (t == 2) {
          if (freq[i][a] && freq[i][b]) {
            cl += freq[i][a] + freq[i][b];
          }
        } else if (t == 1) {
          cl += freq[i][a];
          cl += freq[i][b];
        }
      }
      if (cl > mxl) {
        mxl = cl;
      }
    }
  }
  printf("%d\n", mxl);
  return 0;
}
