#include <bits/stdc++.h>
using namespace std;
int x[26];
int ans = 0;
map<string, int> m, m2;
int main() {
  int n;
  cin >> n;
  while (n--) {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) x[s[i] - 97]++;
    string temp = "";
    for (int i = 0; i < 26; ++i) {
      if (x[i] > 0) {
        char t = i + 97;
        temp = temp + t;
      }
    }
    if (temp.size() == 1) {
      m[temp] += s.size();
      ans = max(ans, m[temp]);
    }
    if (temp.size() == 2) {
      m2[temp] += s.size();
      ans = max(ans, m2[temp]);
    }
    for (int i = 0; i < 26; ++i) x[i] = 0;
  }
  for (auto it = m.begin(); it != m.end(); ++it) {
    for (auto it2 = it; it2 != m.end(); ++it2) {
      string temp = it->first;
      int coun = it->second;
      if (it != it2) {
        ans = max(ans, it->second + it2->second);
        temp += it2->first;
        coun += it2->second;
      }
      for (auto it3 = m2.begin(); it3 != m2.end(); it3++) {
        string tes = it3->first;
        if (tes.find(temp) != -1) ans = max(ans, it3->second + coun);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
