#include <bits/stdc++.h>
using namespace std;
const long long inf = 1000000000ll;
const long long inf64 = inf * inf;
const long long base = inf + 7;
const double pi = 3.1415926535897932384626433832795;
bool solve() {
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  for (char k1 = 'a'; k1 <= 'z'; k1++) {
    for (char k2 = 'a'; k2 <= 'z'; k2++) {
      int tmp = 0;
      for (int i = 0; i < n; i++) {
        int ok = 1;
        for (int j = 0; j < (int)a[i].size(); j++) {
          if (a[i][j] != k1 && a[i][j] != k2) {
            ok = 0;
            break;
          }
        }
        if (ok) tmp += (int)a[i].size();
      }
      ans = max(ans, tmp);
    }
  }
  cout << ans << '\n';
  return true;
}
int main() {
  solve();
  return 0;
}
