#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, len = 0, max = 0, flag = 1;
  cin >> n;
  string alpha = "abcdefghijklmnopqrstuvwxyz";
  vector<string> vs(n);
  for (int i = 0; i < n; i++) cin >> vs[i];
  for (auto i : alpha) {
    for (auto j : alpha) {
      len = 0;
      for (auto k : vs) {
        flag = 1;
        for (auto l : k) {
          if (l != i && l != j) {
            flag = 0;
            break;
          }
        }
        if (flag) len += k.size();
      }
      if (len > max) max = len;
    }
  }
  cout << max;
  return 0;
}
