#include <bits/stdc++.h>
using namespace std;
string arr[101];
int n;
map<pair<int, int>, int> best;
int dfs(int vis = 0, int i = 0) {
  if (i == n) return 1;
  if (best[make_pair(vis, i)] != 0) return best[make_pair(vis, i)];
  int vis2 = vis;
  for (int j = 0; j < arr[i].length(); j++) {
    vis2 |= (1 << (arr[i][j] - 'a'));
  }
  int count = 0;
  for (int i = 0; i < 27; i++) count += ((vis2 & (1 << i)) != 0);
  if (count > 2) return best[make_pair(vis, i)] = dfs(vis, i + 1);
  return best[make_pair(vis, i)] =
             max((int)arr[i].length() + dfs(vis2, i + 1), dfs(vis, i + 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sort(arr[i].begin(), arr[i].end());
    int count = 0;
    for (int j = 1; j < arr[i].length(); j++) {
      if (arr[i][j] != arr[i][j - 1]) count++;
    }
    if (count > 2) {
      i--;
      n--;
    }
  }
  cout << dfs() - 1;
  return 0;
}
