#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double esp = 1e-8;
const int msz = 10000;
const int mod = 1e9 + 7;
struct Tr {
  char s[26];
  int len, l;
};
Tr s[111];
bool vis[26];
int main() {
  char str[1111];
  int n, ans;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", str);
    s[i].len = strlen(str);
    s[i].l = 0;
    memset(vis, 0, sizeof(vis));
    for (int j = 0; j < s[i].len; ++j) {
      if (!vis[str[j] - 'a']) {
        vis[str[j] - 'a'] = 1;
        s[i].s[s[i].l++] = str[j];
      }
    }
  }
  int mx = 0;
  for (int i = 'a'; i <= 'z'; ++i) {
    for (int j = i; j <= 'z'; ++j) {
      ans = 0;
      for (int k = 0; k < n; ++k) {
        if (s[k].l == 1 && (s[k].s[0] == i || s[k].s[0] == j))
          ans += s[k].len;
        else if (s[k].l == 2 && ((s[k].s[0] == i && s[k].s[1] == j) ||
                                 (s[k].s[1] == i && s[k].s[0] == j)))
          ans += s[k].len;
      }
      mx = max(mx, ans);
    }
  }
  printf("%d\n", mx);
  return 0;
}
