#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, ans = 0, now;
  cin >> n;
  string s;
  vector<vector<int>> b(26, vector<int>(n, 0));
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> s;
    a[i] = s.size();
    for (int j = 0; j < a[i]; ++j) {
      ++b[int(s[j] - 'a')][i];
    }
  }
  for (int i = 0; i < 25; ++i) {
    for (int j = i + 1; j < 26; ++j) {
      now = 0;
      for (int h = 0; h < n; ++h) {
        if (b[i][h] + b[j][h] == a[h]) now += a[h];
      }
      if (now > ans) ans = now;
    }
  }
  cout << ans << '\n';
  return 0;
}
