#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 + 5;
string a[MAXN];
int each[MAXN];
bool is[MAXN];
char x[MAXN], y[MAXN];
pair<int, int> cnt[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < MAXN; i++) x[i] = y[i] = '#';
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    bool f = 0;
    for (int j = 0; j < a[i].size(); j++) {
      if (a[i][j] == x[i] || a[i][j] == y[i]) continue;
      if (x[i] == '#') {
        x[i] = a[i][j];
        continue;
      }
      if (y[i] == '#') {
        y[i] = a[i][j];
        continue;
      }
      is[i] = 1;
      break;
    }
  }
  int mxsz = 0;
  for (char i = 'a'; i < 'z'; i++)
    for (char j = i + 1; j <= 'z'; j++) {
      int sz = 0;
      for (int k = 0; k < n; k++)
        if (!is[k])
          if ((x[k] == i || x[k] == j) &&
              (y[k] == '#' || y[k] == i || y[k] == j))
            sz += a[k].size();
      mxsz = max(mxsz, sz);
    }
  cout << mxsz << endl;
}
