#include <bits/stdc++.h>
using namespace std;
struct sort_pred {
  bool operator()(const std::pair<int, int> &left,
                  const std::pair<int, int> &right) {
    return left.second < right.second;
  }
};
int main() {
  int n;
  cin >> n;
  string s[101];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  int maxv = 0;
  for (int i = 0; i < 26; i++) {
    for (int j = i + 1; j < 26; j++) {
      char a = 'a' + i;
      char b = 'a' + j;
      int cnt = 0;
      for (int k = 0; k < n; k++) {
        bool fail = false;
        for (int k1 = 0; k1 < s[k].length(); k1++) {
          if (s[k][k1] == a || s[k][k1] == b) {
            continue;
          } else {
            fail = true;
            break;
          }
        }
        if (!fail) {
          cnt += s[k].length();
        }
      }
      maxv = max(maxv, cnt);
    }
  }
  printf("%d\n", maxv);
  return 0;
}
