#include <bits/stdc++.h>
using namespace std;
int n;
int cnt[30][30];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    int x = 0, y = 0;
    for (char j = 'a'; j <= 'z'; ++j) {
      bool flag = false;
      for (int k = 0; k < (int)s.size(); ++k)
        if (s[k] == j) {
          flag = true;
          break;
        }
      if (flag) {
        if (x == 0)
          x = j - 'a' + 1;
        else if (y == 0)
          y = j - 'a' + 1;
        else {
          x = 30, y = 30;
          break;
        }
      }
    }
    cnt[x][y] += s.size();
    cnt[y][x] += s.size();
  }
  int mx = 0;
  for (int i = 1; i <= 26; ++i) {
    for (int j = 1; j <= 26; ++j) {
      if (i != j) mx = max(mx, cnt[i][j] + cnt[0][i] + cnt[0][j]);
    }
  }
  cout << mx << endl;
}
