#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const double PI = acos(-1);
const double eps = 1e-6;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int n;
string s;
int f[33];
int sum[33][33];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    memset(f, 0, sizeof(f));
    int cnt = 0;
    string t = "";
    for (int j = 0; j < s.size(); j++) {
      if (!f[s[j] - 'a']) {
        f[s[j] - 'a']++;
        cnt++;
        t += s[j];
      }
    }
    if (cnt > 2) continue;
    sort(t.begin(), t.end());
    if (cnt == 2) {
      sum[t[0] - 'a'][t[1] - 'a'] += s.size();
    }
    if (cnt == 1) {
      int k = t[0] - 'a';
      for (int j = 0; j < 26; j++) {
        int a = k, b = j;
        if (a > b) swap(a, b);
        sum[a][b] += s.size();
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < 26; i++) {
    for (int j = i; j < 26; j++) {
      ans = max(ans, sum[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}
