#include <bits/stdc++.h>
using namespace std;
const int N = 222;
string s[N];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  int mx = 0, sum = 0;
  for (char c = 'a'; c <= 'z'; c++) {
    for (char x = c + 1; x <= 'z'; x++) {
      sum = 0;
      for (int i = 0; i < n; i++) {
        bool f = 1;
        for (int j = 0; j < s[i].size(); j++) {
          if (s[i][j] == c || s[i][j] == x)
            continue;
          else {
            f = 0;
            break;
          }
        }
        if (f) sum += s[i].size();
      }
      mx = max(mx, sum);
    }
  }
  cout << mx << "\n";
  return 0;
}
