#include <bits/stdc++.h>
using namespace std;
struct cmp {
  bool operator()(const int& a, const int& b) const { return a > b; }
};
long long mod = 1000000007LL;
long long c[1001][1001];
long long dp[1001];
int main() {
  int n;
  cin >> n;
  set<char> totlet;
  vector<string> ve;
  for (int i = 0; i < n; ++i) {
    string t;
    cin >> t;
    map<char, int> m;
    for (int j = 0; j < t.length(); ++j) {
      m[t[j]]++;
    }
    if (m.size() <= 2 && m.size() > 0) {
      for (int j = 0; j < t.length(); ++j) {
        totlet.insert(t[j]);
      }
      ve.push_back(t);
    }
  }
  int ans = 0;
  for (auto i = totlet.begin(); i != totlet.end(); ++i) {
    for (auto j = totlet.begin(); j != totlet.end(); ++j) {
      int curbest = 0;
      for (int k = 0; k < ve.size(); ++k) {
        bool flag = true;
        for (int r = 0; r < ve[k].length(); ++r) {
          if (ve[k][r] != *i && ve[k][r] != *j) {
            flag = 0;
            break;
          }
        }
        if (flag) curbest += ve[k].length();
      }
      ans = max(ans, curbest);
    }
  }
  cout << ans;
  return 0;
}
