#include <bits/stdc++.h>
using namespace std;
void fre() {
  freopen("c://test//input.in", "r", stdin);
  freopen("c://test//output.out", "w", stdout);
}
template <class T>
inline void gmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline void gmin(T &a, T b) {
  if (b < a) a = b;
}
const int N = 0, M = 0, Z = 1e9 + 7, ms63 = 1061109567;
char s[105][1010];
int n;
int check1(char s[], char x) {
  int len = strlen(s);
  for (int i = 0; i < len; i++)
    if (s[i] != x) return 0;
  return len;
}
int check2(char s[], char x, char y) {
  int len = strlen(s);
  for (int i = 0; i < len; i++)
    if (s[i] != x && s[i] != y) return 0;
  return len;
}
int main() {
  while (~scanf("%d", &n)) {
    int ans = 0;
    for (int i = 1; i <= n; i++) scanf("%s", s[i]);
    for (char x = 'a'; x <= 'z'; x++) {
      int tmp = 0;
      for (int i = 1; i <= n; i++) tmp += check1(s[i], x);
      gmax(ans, tmp);
      for (char y = x + 1; y <= 'z'; y++) {
        tmp = 0;
        for (int i = 1; i <= n; i++) tmp += check2(s[i], x, y);
        gmax(ans, tmp);
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
