#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int a[40][40];
set<int> st;
set<int>::iterator it;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    st.clear();
    cin >> s;
    int len = (int)s.size();
    for (int j = 0; j <= len - 1; ++j) st.insert(s[j] - 'a' + 1);
    if ((int)st.size() > 2) continue;
    if ((int)st.size() == 1) {
      it = st.begin();
      int l1 = *it;
      for (int j = 1; j <= 26; ++j)
        if (l1 != j) a[l1][j] += len, a[j][l1] += len;
      a[l1][l1] += len;
    } else {
      it = st.begin();
      int l1 = *it;
      ++it;
      int l2 = *it;
      a[l1][l2] += len;
      a[l2][l1] += len;
    }
  }
  int res = 0;
  for (int i = 1; i <= 26; ++i) {
    for (int j = 1; j <= 26; ++j) res = max(res, a[i][j]);
  }
  cout << res << endl;
}
