#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  int ret[26][26];
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 26; j++) {
      ret[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    bool A[26];
    for (int j = 0; j < 26; j++) {
      A[j] = false;
    }
    cin >> s;
    int cnt = 0;
    int sum = 0;
    vector<int> S;
    for (int j = 0; j < s.size(); j++) {
      if (!A[s[j] - 'a']) {
        cnt++;
        S.push_back(s[j] - 'a');
      }
      if (cnt > 2) {
        break;
      }
      A[s[j] - 'a'] = true;
      sum++;
    }
    if (cnt > 2) continue;
    if (cnt == 2) {
      if (S[0] > S[1]) {
        ret[S[1]][S[0]] += sum;
      } else {
        ret[S[0]][S[1]] += sum;
      }
    } else {
      ret[S[0]][S[0]] += sum;
    }
  }
  int ans = 0;
  for (int i = 0; i < 26; i++) {
    for (int j = i + 1; j < 26; j++) {
      if (ans < ret[i][j] + ret[i][i] + ret[j][j]) {
        ans = ret[i][j] + ret[i][i] + ret[j][j];
      }
    }
  }
  cout << ans << endl;
  return 0;
}
