#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1001;
const int INF = 1000000000;
int main() {
  int n;
  cin >> n;
  vector<string> words(n);
  for (int i = 0; i < n; i++) {
    cin >> words[i];
  }
  int res = 0;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 26; j++) {
      int sum = 0;
      for (int w = 0; w < n; w++) {
        bool ok = 1;
        for (int c = 0; c < int(words[w].size()); c++) {
          if (words[w][c] != ('a' + i) && words[w][c] != ('a' + j)) {
            ok = false;
            break;
          }
        }
        if (ok) sum += int(words[w].size());
      }
      res = max(res, sum);
    }
  }
  cout << res << endl;
  return 0;
}
