#include <bits/stdc++.h>
using namespace std;
const int maxn = 111;
int n;
string a[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int ans = 0;
  for (char c = 'a'; c <= 'z'; c++)
    for (char d = c; d <= 'z'; d++) {
      int res = 0;
      for (int i = 1; i <= n; i++) {
        bool kt = true;
        for (int j = 0; j <= a[i].size() - 1; j++)
          if (a[i][j] != c && a[i][j] != d) {
            kt = false;
            break;
          }
        if (kt) res += a[i].size();
      }
      ans = max(ans, res);
    }
  cout << ans << endl;
  return 0;
}
