#include <bits/stdc++.h>
using namespace std;
int ans[26][26];
int main() {
  int n;
  cin >> n;
  string s;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    set<int> ch;
    for (int i = 0; i < s.size(); ++i) {
      ch.insert(s[i] - 'a');
      if (ch.size() > 2) break;
    }
    if (ch.size() > 2) continue;
    int a[2];
    int k = 0;
    for (int it : ch) {
      a[k++] = it;
    }
    if (ch.size() == 1) a[1] = a[0];
    ans[a[0]][a[1]] += s.size();
  }
  int tot = 0;
  for (int i = 0; i < 26; ++i) {
    for (int j = 0; j < 26; ++j) {
      if (i != j)
        tot = max(tot, ans[i][j] + ans[i][i] + ans[j][j]);
      else
        tot = max(tot, ans[i][j]);
    }
  }
  cout << tot << '\n';
}
