#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
const int INF = 0x3f3f3f3f;
int mar[30][30];
int vis[30];
char arr[MAXN][MAXN * 10];
int _get(int x) {
  int cnt = 0;
  while (x) {
    x &= (x - 1);
    cnt++;
  }
  return cnt;
}
int main() {
  int n;
  while (~scanf("%d", &n)) {
    memset(mar, 0, sizeof(mar));
    for (int i = 0; i < n; i++) scanf("%s", arr[i]);
    for (int i = 0; i < n; i++) {
      int len = strlen(arr[i]);
      memset(vis, 0, sizeof(vis));
      int cnt = 0, flag = 1;
      int a[5];
      for (int j = 0; j < len; j++) {
        if (!vis[arr[i][j] - 'a']) {
          a[cnt++] = arr[i][j] - 'a';
          vis[arr[i][j] - 'a'] = 1;
        }
        if (cnt > 2) {
          flag = 0;
          break;
        }
      }
      if (flag) {
        int xx = a[0], yy;
        if (cnt == 1)
          mar[xx][xx] += strlen(arr[i]);
        else {
          yy = a[1];
          mar[xx][yy] += strlen(arr[i]);
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < 26; i++)
      for (int j = i + 1; j < 26; j++)
        ans = max(ans, mar[i][j] + mar[j][i] + mar[i][i] + mar[j][j]);
    printf("%d\n", ans);
  }
  return 0;
}
