#include <bits/stdc++.h>
using namespace std;
long long int extgcd(long long int a, long long int b, long long int& x,
                     long long int& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    int g = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return g;
  }
}
long long int hcf(long long int a, long long int b) {
  if (b > a) return (hcf(b, a));
  if (a % b == 0) return b;
  return (hcf(b, a % b));
}
long long int modpow(long long int a, long long int b) {
  long long int res = 1;
  a %= 1000000007;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
int p[10011][26];
int l[10011];
int main() {
  int n;
  cin >> n;
  string s;
  for (int i = (int)1; i <= (int)n; ++i) {
    cin >> s;
    for (int j = (int)0; j < (int)s.length(); ++j) p[i][s[j] - 'a']++;
    l[i] = s.length();
  }
  int cnt = 0;
  for (int i = (int)0; i < (int)26; ++i) {
    for (int j = (int)i + 1; j < (int)26; ++j) {
      int cnt1 = 0, x = i, y = j;
      for (int k = (int)1; k <= (int)n; ++k) {
        bool flag = false;
        for (int l = (int)0; l < (int)26; ++l) {
          if (l != x && l != y && p[k][l] > 0) {
            flag = true;
            break;
          }
        }
        if (flag) continue;
        cnt1 += l[k];
      }
      cnt = (cnt1 > cnt) ? cnt1 : cnt;
    }
  }
  cout << cnt << "\n";
  return 0;
}
