#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n;
string a[1000];
bool ok(char x, char y, string &second) {
  for (int i = 0; i < (int)second.size(); i++) {
    if (second[i] != x && second[i] != y) return false;
  }
  return true;
}
int main() {
  int ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (char x = 'a'; x <= 'z'; x++) {
    for (char y = x + 1; y <= 'z'; y++) {
      int cur = 0;
      for (int i = 0; i < n; i++)
        if (ok(x, y, a[i])) cur += a[i].size();
      ans = max(ans, cur);
    }
  }
  cout << ans << endl;
  return 0;
}
