#include <bits/stdc++.h>
using namespace std;
string s[102];
int main() {
  int n, i, cnt[27], j, k;
  cin >> n;
  for (i = 0; i < n; i++) cin >> s[i];
  int ans = 0, temp, first, second, x, r;
  for (i = 1; i <= 26; i++) {
    for (j = 1; j <= 26; j++) {
      temp = 0;
      for (k = 0; k < n; k++) {
        memset(cnt, 0, sizeof(cnt));
        x = 0;
        for (r = 0; r < s[k].size(); r++) {
          cnt[(int)s[k][r] - 96]++;
        }
        for (r = 1; r <= 26; r++) {
          if (cnt[r]) x++;
        }
        if (x <= 2) {
          int flag = 0;
          for (r = 1; r <= 26; r++) {
            if (cnt[r]) {
              if (r != i && r != j) flag = 1;
            }
          }
          if (flag == 0) temp += s[k].size();
        }
      }
      ans = max(ans, temp);
    }
  }
  cout << ans << endl;
  return 0;
}
