#include <bits/stdc++.h>
using namespace std;
int ans[300][300];
int used[300];
int main() {
  int i, n;
  string s;
  cin >> n;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < 30; i++) used[i] = 0;
    cin >> s;
    int dif = 0;
    char first = 0;
    char second = 0;
    for (int i = 0; i < s.size(); i++) {
      char ch = s[i] - 'a';
      if (used[ch] == 0) {
        dif++;
        if (first == 0)
          first = ch;
        else if (second == 0)
          second = ch;
      }
      used[ch]++;
    }
    if (dif == 1) {
      ans[first][first] += used[first];
    }
    if (dif == 2) {
      ans[first][second] += used[first];
      ans[second][first] += used[second];
    }
  }
  int max = 0;
  for (int i = 0; i < 30; i++)
    for (int j = 0; j < 30; j++)
      if (i != j) {
        if (max < ans[i][j] + ans[j][i] + ans[i][i] + ans[j][j])
          max = ans[i][j] + ans[j][i] + ans[i][i] + ans[j][j];
      } else if (max < ans[i][i])
        max = ans[i][i];
  cout << max << endl;
  return 0;
}
