#include <bits/stdc++.h>
const int MAX_L = 2005;
const int INF_INT = 0x3f3f3f3f;
const long long INF_LL = 0x7fffffff;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const double pi = acos(-1);
using namespace std;
int n;
int a[26], b[26][26];
int main() {
  while (cin >> n) {
    string s;
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    for (int i = 1; i <= n; i++) {
      cin >> s;
      set<char> st;
      for (int i = 0; i < s.size(); i++) st.insert(s[i]);
      if (st.size() > 2) continue;
      if (st.size() == 1)
        a[s[0] - 'a'] += s.size();
      else if (st.size() == 2) {
        char tmp[2];
        int t = 0;
        for (auto &i : st) {
          tmp[t++] = i;
        }
        b[tmp[0] - 'a'][tmp[1] - 'a'] += s.size();
        b[tmp[1] - 'a'][tmp[0] - 'a'] += s.size();
      }
    }
    int ans = 0;
    for (int i = 0; i < 26; i++) {
      for (int j = 0; j < 26; j++) {
        if (i == j) continue;
        ans = max(ans, a[i] + a[j] + b[i][j]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
