#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> s;
  for (int i = 0; i < n; i++) {
    string z;
    cin >> z;
    s.push_back(z);
  }
  int max = 0;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 26; j++) {
      int cnt = 0;
      for (int k = 0; k < s.size(); k++) {
        bool flag = true;
        for (int x = 0; x < s[k].size(); x++) {
          if (s[k][x] - 'a' != i && s[k][x] - 'a' != j) {
            flag = false;
            break;
          }
        }
        if (flag) cnt += s[k].size();
      }
      if (max < cnt) max = cnt;
    }
  }
  cout << max << endl;
  return 0;
}
