#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  int ans = 0;
  for (char a = 'a'; a <= 'z'; ++a) {
    for (char b = 'a'; b <= 'z'; ++b) {
      int cnt = 0;
      for (int i = 0; i < n; ++i) {
        bool ok = true;
        for (int j = 0; j < (int)(v[i]).size(); ++j) {
          if (v[i][j] != a && v[i][j] != b) {
            ok = false;
            break;
          }
        }
        if (ok) {
          cnt += (int)(v[i]).size();
        }
      }
      ans = max(ans, cnt);
    }
  }
  cout << ans << "\n";
}
