#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long sum = 0;
  string s2, s1;
  map<pair<char, char>, long long> mp;
  while (n--) {
    cin >> s1;
    sort(s1.begin(), s1.end());
    if (s1[s1.size() - 1] - s1[0] == 0) {
      for (int i = 0; i < 26; i++) {
        char v = 'a' + i;
        char g = s1[0];
        if (g > v) swap(g, v);
        mp[{g, v}] += s1.size();
        sum = max(sum, mp[{g, v}]);
      }
    } else {
      int y = 1;
      for (int i = 1; i < s1.size(); i++) {
        if (s1[i] != s1[i - 1]) y++;
      }
      if (y == 2) {
        char v = s1[s1.size() - 1];
        char g = s1[0];
        mp[{g, v}] += s1.size();
        sum = max(sum, mp[{g, v}]);
      }
    }
  }
  cout << sum;
  return 0;
}
