#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 55;
const int INF = 1e9 + 77;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
const double EPS = 1e-7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  int ans = 0;
  for (char ch1 = 'a'; ch1 <= 'z'; ++ch1) {
    for (char ch2 = ch1 + 1; ch2 <= 'z'; ++ch2) {
      int cur = 0;
      for (int i = 0; i < n; ++i) {
        bool flag = 1;
        for (int j = 0; j < v[i].length(); ++j) {
          if (v[i][j] != ch1 && v[i][j] != ch2) {
            flag = 0;
            break;
          }
        }
        if (flag) {
          cur += v[i].length();
        }
      }
      ans = max(ans, cur);
    }
  }
  cout << ans;
  return 0;
}
