#include <bits/stdc++.h>
using namespace std;
struct T {
  int num = 0;
  int k = 0;
  bool vis[27] = {0};
} str[110];
int n;
int f(int i, int j) {
  int sum = 0;
  for (int h = 0; h < n; h++) {
    if (str[h].k == 2 && str[h].vis[i] && str[h].vis[j]) sum += str[h].num;
    if (str[h].k == 1 && (str[h].vis[i] || str[h].vis[j])) sum += str[h].num;
  }
  return sum;
}
int main() {
  int j, i;
  char s;
  scanf("%d", &n);
  getchar();
  for (i = 0; i < n; i++) {
    while (scanf("%c", &s) && s != 10) {
      if (str[i].vis[s - 'a'] == 0) {
        str[i].vis[s - 'a'] = 1;
        str[i].k++;
      }
      str[i].num++;
    }
  }
  int m = 0, ans = 0;
  for (i = 0; i < 25; i++) {
    for (j = i + 1; j <= 25; j++) {
      m = f(i, j);
      ans = max(ans, m);
    }
  }
  printf("%d\n", ans);
  return 0;
}
