#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
long long mod = 1e9 + 7;
long long const INFll = 1e18;
long double INFld = 28e14;
long long const INF = 2e9;
long double const eps = 1e-7;
long double const pi = acos(-1.0);
using namespace std;
struct __debug__ {
  __debug__(string filename) {
    ios_base::sync_with_stdio(0);
    string filein = filename + ".in";
    string fileout = filename + ".out";
  }
  ~__debug__() {}
} __Debug__("mincut");
const int MAXN = 105;
int a[256];
int b[MAXN];
vector<string> q;
int n;
int f(char c1, char c2) {
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int ok = 1;
    string st1 = q[i];
    for (char c : st1) {
      if (c != c1 && c != c2) {
        ok = 0;
        break;
      }
    }
    if (ok) ans += st1.size();
  }
  return ans;
}
int main() {
  char c;
  cin >> n;
  string st;
  for (int i = 0; i < n; i++) {
    cin >> st;
    char c1 = 0;
    char c2 = 0;
    bool ok = 1;
    if (ok) {
      q.push_back(st);
    }
  }
  int mx = 0;
  for (char c1 = 'a'; c1 <= 'z'; c1++) {
    for (char c2 = c1 + 1; c2 <= 'z'; c2++) {
      mx = max(mx, f(c1, c2));
    }
  }
  cout << mx;
}
