#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 1, -1}, dy[] = {-1, -1, 1, 1};
int main() {
  int num;
  scanf("%d", &num);
  vector<string> Words(num);
  for (int i = 0; i < num; i++) {
    cin >> Words[i];
  }
  int maxx = 0, cnt = 0;
  for (int i = 'a'; i <= 'z'; i++) {
    for (int j = i + 1; j <= 'z'; j++) {
      cnt = 0;
      for (int n = 0; n < Words.size(); n++) {
        bool can = true;
        for (int z = 0; z < Words[n].size(); z++) {
          if (Words[n][z] != i && Words[n][z] != j) {
            can = 0;
            break;
          }
        }
        if (can) cnt += Words[n].size();
      }
      maxx = max(maxx, cnt);
    }
  }
  printf("%d", maxx);
  return 0;
}
