#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  unsigned int size, temp;
  vector<unsigned int> lengthes;
  cin >> size;
  vector<string> words(size);
  for (int i = 0; i < size; i++) {
    cin >> words[i];
  }
  for (int i = 97; i <= 122; i++) {
    for (int j = 97; j <= 122; j++) {
      temp = 0;
      for (int k = 0; k < size; k++) {
        bool take = true;
        for (int s = 0; s < words[k].size(); s++) {
          if ((words[k][s] != i) && (words[k][s] != j)) {
            take = false;
            break;
          }
        }
        if (take) {
          temp += words[k].size();
        }
      }
      lengthes.push_back(temp);
    }
  }
  cout << *max_element(lengthes.begin(), lengthes.end()) << endl;
  return 0;
}
