#include <bits/stdc++.h>
using namespace std;
char str[105][1005];
vector<int> v[30][30];
int flag[30], cnt, x, y;
int main() {
  int i, j, n, m, l, vans, ans = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%s", str[i] + 1);
  }
  for (i = 1; i <= n; i++) {
    m = strlen(str[i] + 1);
    memset(flag, 0, sizeof(flag));
    cnt = 0;
    for (j = 1; j <= m; j++) {
      if (flag[str[i][j] - 'a' + 1] == 0) {
        flag[str[i][j] - 'a' + 1] = 1;
        cnt++;
        y = x;
        x = str[i][j] - 'a' + 1;
      }
    }
    if (cnt == 1) {
      v[0][x].push_back(i);
    } else if (cnt == 2) {
      v[min(x, y)][max(x, y)].push_back(i);
    }
  }
  for (i = 1; i <= 26; i++) {
    for (j = i + 1; j <= 26; j++) {
      vans = 0;
      int e = v[i][j].size();
      for (l = 0; l < e; l++) {
        vans += strlen(str[v[i][j][l]] + 1);
      }
      e = v[0][j].size();
      for (l = 0; l < e; l++) {
        vans += strlen(str[v[0][j][l]] + 1);
      }
      e = v[0][i].size();
      for (l = 0; l < e; l++) {
        vans += strlen(str[v[0][i][l]] + 1);
      }
      ans = max(ans, vans);
    }
  }
  printf("%d\n", ans);
  return 0;
}
