#include <bits/stdc++.h>
using namespace std;
string second[105];
int main() {
  int n;
  cin >> n;
  for (int i = (int)1; i <= (int)n; i++) {
    cin >> second[i];
  }
  int ans = 0;
  for (int i = (int)0; i <= (int)25; i++) {
    for (int j = (int)i + 1; j <= (int)25; j++) {
      int sum = 0;
      for (int k = (int)1; k <= (int)n; k++) {
        int l = second[k].length();
        bool fl = 0;
        for (int z = (int)0; z <= (int)l - 1; z++)
          if (second[k][z] - 'a' != i && second[k][z] - 'a' != j) fl = 1;
        if (fl == 0) sum += second[k].length();
      }
      ans = max(sum, ans);
    }
  }
  cout << ans << endl;
}
