#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  bool f;
  int n, mx = 0, cnt;
  cin >> n;
  string s[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < 26; i++) {
    for (int j = i; j < 26; j++) {
      cnt = 0;
      for (int k = 0; k < n; k++) {
        f = 1;
        for (int l = 0; l < s[k].size(); l++)
          if (s[k][l] != ('a' + i) && s[k][l] != ('a' + j)) {
            f = 0;
            break;
          }
        if (f) cnt += s[k].size();
      }
      if (cnt > mx) mx = cnt;
    }
  }
  cout << mx;
  return 0;
}
