#include <bits/stdc++.h>
using namespace std;
long long int n, m, i, j, k, l, T, u, v, q, t = 0, t1 = 0, te, c = 0;
long long int a[1010], b[1010], ans = 0;
long long int dp[26][26];
int main() {
  std::ios::sync_with_stdio(false);
  vector<string> s;
  vector<pair<int, int> > p;
  string s1, s2;
  cin >> n;
  getline(cin, s2);
  for (int i = 0; i < n; i++) {
    bool a[26];
    vector<int> v;
    int t = 0;
    for (int j = 0; j < 26; j++) {
      a[j] = 0;
    }
    getline(cin, s1);
    for (int j = 0; j < s1.size(); j++) {
      a[s1[j] - 'a'] = 1;
    }
    for (int j = 0; j < 26; j++) {
      if (a[j] == 1) {
        t++;
        v.push_back(j);
      }
    }
    if (t == 1) {
      s.push_back(s1);
      p.push_back(make_pair(v[0], 27));
    }
    if (t == 2) {
      s.push_back(s1);
      p.push_back(make_pair(v[0], v[1]));
    }
  }
  for (int k = 0; k < 26; k++) {
    for (int l = k; l < 26; l++) {
      dp[k][l] = 0;
      for (int i = 0; i < s.size(); i++) {
        if (k == p[i].first) {
          if ((l == p[i].second) or (p[i].second > 26)) dp[k][l] += s[i].size();
        } else if ((l == p[i].first) and (p[i].second > 26))
          dp[k][l] += s[i].size();
      }
      ans = max(ans, dp[k][l]);
    }
  }
  cout << ans;
}
