#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string str[110];
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> str[i];
  int ans = 0;
  for (int i = 0; i < 26; i++) {
    for (int j = 1; j <= n; j++) {
      int sum = 0;
      for (int k = 0; k < str[j].size(); k++) {
        if (str[j][k] != i + 'a') break;
        if (k == str[j].size() - 1) sum += str[j].size();
      }
      ans = max(sum, ans);
    }
    for (int j = 0; j < 26; j++) {
      int sum = 0;
      for (int l = 1; l <= n; l++) {
        for (int k = 0; k < str[l].size(); k++) {
          if (str[l][k] != i + 'a' && str[l][k] != j + 'a') break;
          if (k == str[l].size() - 1) sum += str[l].size();
        }
      }
      ans = max(sum, ans);
    }
  }
  cout << ans << endl;
}
