#include <bits/stdc++.h>
using namespace std;
bool is(string s, char a, char b) {
  for (unsigned int i = 0; i < s.length(); i++) {
    if (s[i] != a && s[i] != b) {
      return false;
    }
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  string w[n];
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  int maxsum = 0;
  for (char a = 'a'; a <= 'y'; a++) {
    for (char b = a + 1; b <= 'z'; b++) {
      int sum = 0;
      for (int i = 0; i < n; i++) {
        if (is(w[i], a, b)) {
          sum += w[i].length();
        }
      }
      if (sum > maxsum) {
        maxsum = sum;
      }
    }
  }
  cout << maxsum;
  return 0;
}
