#include <bits/stdc++.h>
using namespace std;
int main() {
  string ss[100];
  int n, ans = 0, cur;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> ss[i];
  for (char a = 'a'; a <= 'z'; a++)
    for (char b = 'a'; b <= 'z'; b++) {
      cur = 0;
      for (int i = 0; i < n; i++) {
        int l = ss[i].length();
        bool ok = true;
        while (l--) {
          if (ss[i][l] != a && ss[i][l] != b) ok = false;
        }
        if (ok) cur += ss[i].length();
      }
      ans = max(ans, cur);
    }
  cout << ans;
  return 0;
}
