#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b, long long m) {
  long long ret = 1;
  while (b) {
    if (b % 2) ret = ((ret % m) * (a % m)) % m;
    a = ((a % m) * (a % m)) % m;
    b /= 2;
  }
  return ret;
}
void ya() {
  cout << "YES";
  exit(0);
}
void no() {
  cout << "NO";
  exit(0);
}
int main() {
  int n;
  cin >> n;
  map<char, int> m[n];
  int len[n];
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    len[i] = s.size();
    for (int j = 0; j < s.size(); j++) m[i][s[j]]++;
  }
  int ans = -1;
  for (int i = 'a'; i <= 'z'; i++) {
    for (int j = i + 1; j <= 'z'; j++) {
      int temp = 0;
      for (int k = 0; k < n; k++) {
        int flag = 0;
        for (auto it = m[k].begin(); it != m[k].end(); it++) {
          char ch = it->first;
          if (ch != i && ch != j) {
            flag = 1;
            break;
          }
        }
        if (!flag) temp += len[k];
      }
      ans = max(ans, temp);
    }
  }
  cout << ans;
  return 0;
}
