#include <bits/stdc++.h>
using namespace std;
int a[26][26];
int main() {
  int n, i, j, k, l;
  string s;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s;
    k = 0;
    bool t[26];
    for (j = 0; j < 26; j++) t[j] = false;
    for (j = 0; j < s.length(); j++) t[s[j] - 'a'] = true;
    for (j = 0; j < 26; j++)
      if (t[j]) k++;
    if (k < 3) {
      k = -1;
      l = -1;
      for (j = 0; j < 26; j++)
        if (t[j]) {
          if (k < 0)
            k = j;
          else
            l = j;
        }
      if (l < 0) l = k;
      a[k][l] += s.length();
    }
  }
  int maxx = 0;
  for (i = 0; i < 26; i++)
    for (j = 0; j < 26; j++)
      if (i != j)
        maxx = max(maxx, a[i][j] + a[i][i] + a[j][j]);
      else
        maxx = max(maxx, a[i][j]);
  cout << maxx;
}
