#include <bits/stdc++.h>
int n;
char a[100][1001];
int danhdau[256];
int check(char s[]) {
  int i, j, sl = 1;
  char c[3];
  c[0] = s[0];
  for (i = 0; s[i]; i++) {
    for (j = 0; j < sl; j++) {
      if (s[i] == c[j]) break;
    }
    if (j == sl) {
      c[sl] = s[i];
      sl++;
      if (sl == 3) return 0;
    }
  }
  danhdau[c[0]] = 1;
  danhdau[c[1]] = 1;
  return i;
}
int Cal(char s[], char c1, char c2) {
  int i, j, dem = 0;
  for (i = 0; s[i]; i++) {
    if (s[i] == c1 || s[i] == c2) {
      dem++;
    } else
      return 0;
  }
  return dem;
}
int Solve() {
  int i, j, k, dem = 0;
  int danhdau1[n];
  int max = 0;
  for (i = 'A'; i <= 'z'; i++) {
    danhdau[i] = 0;
  }
  for (i = 0; i < n; i++) {
    danhdau1[i] = check(a[i]);
  }
  for (i = 'a'; i < 'z'; i++) {
    for (j = i + 1; j <= 'z'; j++) {
      dem = 0;
      for (k = 0; k < n; k++) {
        if (danhdau1[k]) dem += Cal(a[k], i, j);
      }
      if (max < dem) {
        max = dem;
      }
    }
  }
  return max;
}
int main() {
  int i, j;
  while (scanf("%d", &n) > 0) {
    for (i = 0; i < n; i++) {
      scanf("%s", a[i]);
    }
    printf("%d\n", Solve());
  }
  return 0;
}
