#include <bits/stdc++.h>
using namespace std;
string x;
struct record {
  char a, b;
  long long l;
  record(char a, char b, long long l) {
    this->a = a;
    this->b = b;
    this->l = l;
  }
};
struct r {
  char a, b;
  r(char a, char b) {
    this->a = a;
    this->b = b;
  }
};
vector<r> v1;
vector<record> v2;
vector<char> v3;
map<char, int> v4;
int main() {
  long long i, j;
  for (i = 97; i <= 122; i++) {
    for (j = i + 1; j <= 122; j++) {
      v1.push_back(r(i, j));
    }
  }
  long long n;
  cin >> n;
  while (n--) {
    cin >> x;
    sort(x.begin(), x.end());
    for (i = 0; i < x.size(); i++) {
      if (v4[x[i]] == 0) {
        v3.push_back(x[i]);
        v4[x[i]] = 1;
      }
    }
    if (v3.size() == 1)
      v2.push_back(record(v3[0], v3[0], x.size()));
    else if (v3.size() == 2)
      v2.push_back(record(v3[0], v3[1], x.size()));
    v4.clear();
    v3.clear();
  }
  long long sum = 0, ma = 0;
  for (i = 0; i < v1.size(); i++) {
    sum = 0;
    for (j = 0; j < v2.size(); j++) {
      if (v2[j].a == v2[j].b) {
        if (v2[j].a == v1[i].b || v2[j].a == v1[i].a) {
          sum = sum + v2[j].l;
        }
      } else if (v2[j].a == v1[i].a && v2[j].b == v1[i].b) {
        sum = sum + v2[j].l;
      }
    }
    ma = max(ma, sum);
  }
  cout << ma << "\n";
}
