#include <bits/stdc++.h>
using namespace std;
bool fun(string a, string b) {}
int number;
int boool[1001];
string s[1001];
string sTest[1001];
int itest;
int res[1001];
int Smax;
int main() {
  cin >> number;
  for (int i = 0; i < number; ++i) {
    cin >> s[i];
    string tmp = "";
    for (int j = 0; j < s[i].size(); ++j) {
      if (tmp.find(s[i][j]) == std::string::npos) {
        tmp += s[i][j];
      }
    }
    sort(tmp.begin(), tmp.end());
    if (tmp.size() <= 2) {
      sTest[i] = tmp;
    }
  }
  for (char i = 'a'; i <= 'z'; ++i) {
    for (char j = i + 1; j <= 'z'; ++j) {
      int res = 0;
      for (int k = 0; k < 1000; ++k) {
        string tmp = "";
        tmp += i;
        tmp += j;
        string tmp1 = "";
        tmp1 += i;
        string tmp2 = "";
        tmp2 += j;
        if (sTest[k] == tmp || sTest[k] == tmp1 || sTest[k] == tmp2) {
          res += s[k].size();
        }
      }
      if (res > Smax) {
        Smax = res;
      }
    }
  }
  cout << Smax;
  return 0;
}
