#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
const long double pi = acos(-1);
int N;
string s[105];
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cout << fixed;
  cout.tie(0);
  cin.tie(0);
  cin >> N;
  for (int(i) = 0; (i) < (N); (i)++) cin >> s[i];
  int ans = 0;
  for (char ch1 = 'a'; ch1 <= 'z'; ch1++)
    for (char ch2 = 'a'; ch2 <= 'z'; ch2++) {
      int sum = 0;
      for (int(i) = 0; (i) < (N); (i)++) {
        int all = 1;
        for (int(j) = 0; (j) < (int((s[i]).size())); (j)++) {
          all &= (s[i][j] == ch1 || s[i][j] == ch2);
        }
        if (all) sum += int((s[i]).size());
      }
      ans = max(ans, sum);
    }
  cout << ans << '\n';
}
