#include <bits/stdc++.h>
using namespace std;
unsigned long long gcdd(unsigned long long a, unsigned long long b) {
  unsigned long long maxx = max(a, b);
  unsigned long long minn = min(a, b);
  a = maxx;
  b = minn;
  if (b == 0) return a;
  return gcdd(b, a % b);
}
string arr[(int)5e5 + 5];
int main() {
  int n, m, ans = 0, jj = 0;
  map<int, int> M;
  vector<int> V;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (char i = 'a'; i <= 'z'; i++) {
    jj = 0;
    for (char j = i + 1; j <= 'z'; j++) {
      jj = 0;
      for (int k = 0; k < n; k++) {
        bool bol = true;
        int llo = arr[k].length();
        for (int p = 0; p < llo; p++) {
          if (arr[k][p] != i && arr[k][p] != j) {
            bol = false;
            break;
          }
        }
        if (bol) {
          jj += llo;
        }
      }
      ans = max(ans, jj);
    }
    ans = max(ans, jj);
  }
  cout << ans;
  return 0;
}
