#include <bits/stdc++.h>
using namespace std;
int dr[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dc[] = {1, -1, 0, 0, 1, -1, 1, -1};
vector<int> m[102];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int f[28], i, j, len, n, cnt, w = 0, word[102];
  char str[1002];
  cin >> n;
  for (int x = 0; x < n; x++) {
    cin >> str;
    memset(f, (0), sizeof(f));
    len = strlen(str);
    for (i = 0; i < len; i++) f[str[i] - 'a']++;
    cnt = 0;
    int m1 = -1, m2 = -1;
    for (i = 0; i < 26; i++) {
      if (f[i] > 0) {
        cnt++;
        if (m1 == -1)
          m1 = i;
        else if (m2 == -1)
          m2 = i;
      }
    }
    if (cnt <= 2) {
      word[w] = len;
      if (m1 != -1) m[w].push_back(m1);
      if (m2 != -1) m[w].push_back(m2);
      w++;
    }
  }
  int mx = 0;
  for (i = 0; i < 25; i++) {
    for (j = i + 1; j < 26; j++) {
      cnt = 0;
      for (int k = 0; k < w; k++) {
        int yes = 1;
        for (int l = 0; l < m[k].size(); l++) {
          if (m[k][l] == i || m[k][l] == j)
            ;
          else {
            yes = 0;
            break;
          }
        }
        if (yes == 1) cnt += word[k];
      }
      mx = max(mx, cnt);
    }
  }
  cout << mx << "\n";
  return 0;
}
