#include <bits/stdc++.h>
using namespace std;
int i, j, n, k, t, maxi, ans, stop;
string a[10001];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 0; i < 26; i++)
    for (j = i + 1; j < 26; j++) {
      for (k = 1; k <= n; k++) {
        stop = 0;
        for (t = 0; t < a[k].size(); t++)
          if (a[k][t] != char(int('a') + i) && a[k][t] != char(int('a') + j)) {
            stop = 1;
            break;
          }
        if (stop == 0) ans = ans + a[k].size();
      }
      maxi = max(maxi, ans);
      ans = 0;
    }
  cout << maxi;
  return 0;
}
