#include <bits/stdc++.h>
using namespace std;
long long int s, m, k, nr1, nr2, n, i, Apa[30], Ap[30][30], j, l, mx;
char sir[10000], a, b, aux;
int main() {
  cin >> n;
  for (j = 0; j < n; j++) {
    cin >> sir;
    l = strlen(sir);
    k = 1;
    nr1 = 1;
    a = sir[0];
    for (i = 1; i < l; i++) {
      if (sir[i] == a)
        nr1++;
      else if (sir[i] != a) {
        if (k == 1) {
          k = 2;
          b = sir[i];
          nr2 = 1;
        } else if (sir[i] == b && k == 2) {
          nr2++;
        } else {
          k = 3;
          break;
        }
      }
    }
    if (k == 1) {
      Apa[a - 'a' + 0] += nr1;
    } else if (k == 2) {
      if (a < b) {
        aux = a;
        a = b;
        b = aux;
      }
      Ap[a - 'a' + 0][b - 'a' + 0] += nr1 + nr2;
    }
  }
  for (i = 0; i < 26; i++)
    for (j = 0; j < 26; j++) {
      if (i != j) {
        s = Ap[i][j] + Apa[i] + Apa[j];
        if (s > mx) mx = s;
      }
    }
  cout << mx;
}
