#include <bits/stdc++.h>
using namespace std;
int main() {
  {
    int n, i, j, k, m, f, s = 0, y = 1, mx = 0;
    scanf("%d", &n);
    string a[n];
    k = n;
    i = 0;
    while (k--) {
      cin >> a[i++];
    }
    for (i = 0; i <= 25; i++) {
      for (j = i; j <= 25; j++) {
        s = 0;
        for (k = 0; k < n; k++) {
          y = 1;
          for (f = 0; f < a[k].length(); f++) {
            if ((a[k][f] - 'a' != i) && (a[k][f] - 'a' != j)) {
              y = 0;
              break;
            }
          }
          if (y == 1) {
            s += a[k].length();
          }
        }
        mx = max(mx, s);
      }
    }
    cout << mx;
  }
  return 0;
}
