#include <bits/stdc++.h>
using namespace std;
map<string, int> counters;
int main() {
  int n;
  cin >> n;
  string word;
  for (int i = 0; i < n; i++) {
    map<char, int> chars;
    cin >> word;
    for (char c : word) chars[c]++;
    string pref;
    for (auto p : chars) pref.push_back(p.first);
    if (pref.size() == 1) {
      for (char c = 'a'; c <= 'z'; c++) {
        string old = pref;
        pref.push_back(c);
        sort(pref.begin(), pref.end());
        counters[pref] += word.size();
        pref = old;
      }
    } else if (pref.size() == 2) {
      sort(pref.begin(), pref.end());
      counters[pref] += word.size();
    }
  }
  int best = 0;
  for (auto& p : counters) {
    best = max(best, p.second);
  }
  cout << best << endl;
  return 0;
}
