#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  {
    long long n, i, j, k, l, cnt, maxi;
    cin >> n;
    string str;
    vector<string> v;
    bool flag = false;
    for (i = 0; i < n; i++) {
      cin >> str;
      v.push_back(str);
    }
    maxi = -1;
    for (i = 0; i < 26; i++) {
      for (j = 0; j < 26; j++) {
        cnt = 0;
        for (k = 0; k < n; k++) {
          flag = false;
          for (l = 0; l < v[k].size(); l++) {
            if (!(v[k][l] - 'a' == i or v[k][l] - 'a' == j)) {
              flag = true;
              break;
            }
          }
          if (!flag) cnt += v[k].size();
        }
        maxi = max(maxi, cnt);
      }
    }
    cout << maxi << '\n';
  }
  cerr << " Execution : " << (1.0 * clock()) / CLOCKS_PER_SEC << "s \n";
  return 0;
}
