#include <bits/stdc++.h>
using namespace std;
const int N = 50;
int val[110][500], cnt[110];
string s[110];
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    for (int j = 0; j < (int)s[i].length(); j++)
      if (!val[i][s[i][j]]) {
        val[i][s[i][j]] = 1, cnt[i]++;
      }
  }
  int ans = 0;
  for (int i = 'a'; i <= 'z'; i++)
    for (int j = i; j <= 'z'; j++) {
      int te = 0;
      for (int k = 1; k <= n; k++) {
        if (cnt[k] > 2) continue;
        if (cnt[k] == 1 && (val[k][i] == 1 || val[k][j] == 1))
          te += s[k].length();
        if (i == j) continue;
        if (cnt[k] == 2 && val[k][i] == 1 && val[k][j] == 1)
          te += s[k].length();
      }
      ans = max(ans, te);
    }
  cout << ans << endl;
}
