#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> S(n);
  for (int i = (0); i < (n); ++i) {
    cin >> S[i];
    sort((S[i]).begin(), (S[i]).end());
  }
  vector<vector<int> > t(26, vector<int>(26, 0));
  for (auto i : S) {
    string tmp = i;
    sort((tmp).begin(), (tmp).end());
    tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());
    if (tmp.size() == 2) t[tmp[0] - 'a'][tmp[1] - 'a'] += i.size();
    if (tmp.size() == 1) t[tmp[0] - 'a'][tmp[0] - 'a'] += i.size();
  }
  int m = 0;
  for (int i = (0); i < (26); ++i)
    for (int j = (0); j < (26); ++j) {
      int tmp = t[i][j];
      if (i != j) tmp += t[i][i] + t[j][j];
      m = max(m, tmp);
    }
  cout << m << endl;
  return 0;
}
