#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int cnt[100][26];
  int len[100];
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  memset(cnt, 0, sizeof(cnt));
  cin >> n;
  string str;
  for (int i = 0; i < n; i++) {
    cin >> str;
    len[i] = str.length();
    for (int j = 0; j < len[i]; j++) {
      cnt[i][str[j] - 'a']++;
    }
  }
  int d = 0;
  int ans = 0;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 26; j++) {
      d = 0;
      for (int k = 0; k < n; k++) {
        if (cnt[k][i] == len[k] ||
            ((i != j) && (cnt[k][j] + cnt[k][i] == len[k]))) {
          d += len[k];
        }
      }
      ans = max(ans, d);
    }
  }
  cout << ans << endl;
  return 0;
}
