#include <bits/stdc++.h>
using namespace std;
long long n, j, i, i1, j2, m1, m2, s;
map<char, long long> a;
string b[101];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  b[0] = "abcdefghijklmnopqrstuvwxyz";
  for (i = 1; i <= n; i++) {
    cin >> b[i];
  }
  m2 = 0;
  for (i = 0; i < b[0].size(); i++) {
    for (j = 0; j < b[0].size(); j++) {
      s = 0;
      for (i1 = 1; i1 <= n; i1++) {
        m1 = 1;
        for (j2 = 0; j2 < b[i1].size(); j2++) {
          if (b[0][i] == b[i1][j2] || b[0][j] == b[i1][j2]) {
            m1 = 1;
          } else {
            m1 = 0;
            break;
          }
        }
        if (m1 == 1) {
          s += b[i1].size();
        }
      }
      if (s > m2) {
        m2 = s;
      }
    }
  }
  cout << m2;
}
