#include <bits/stdc++.h>
using namespace std;
char ch[100][1001];
int cnt[100][26];
int res[100][26];
int rel[100];
int main(void) {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%s", ch[i]);
    int t = 0;
    for (int j = 0; ch[i][j]; j++) {
      if (cnt[i][ch[i][j] - 'a'] == 0) {
        res[i][t] = ch[i][j] - 'a';
        t++;
        rel[i] = t;
      }
      cnt[i][ch[i][j] - 'a']++;
    }
    if (t > 2) {
      for (int j = 0; j < 26; j++) cnt[i][j] = 0;
      i--;
      N--;
    }
  }
  int max = 0;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 26; j++) {
      if (i == j) continue;
      int ccnt = 0;
      for (int k = 0; k < N; k++) {
        if (rel[k] == 1) {
          if (res[k][0] == i) ccnt += cnt[k][i];
          if (res[k][0] == j) ccnt += cnt[k][j];
        } else if (rel[k] == 2) {
          if (res[k][0] == i && res[k][1] == j) ccnt += cnt[k][i] + cnt[k][j];
          if (res[k][0] == j && res[k][1] == i) ccnt += cnt[k][i] + cnt[k][j];
        }
      }
      if (ccnt > max) max = ccnt;
    }
  }
  printf("%d\n", max);
  return 0;
}
