#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int n;
  cin >> n;
  int result[27][27];
  for (int i = 0; i < 27; i++) {
    for (int j = 0; j < 27; j++) {
      result[i][j] = 0;
    }
  }
  char c[1008];
  cin.getline(c, 1001);
  for (int i = 0; i < n; i++) {
    cin.getline(c, 1001);
    int x = 0, y = 0;
    bool less = true;
    int j;
    for (j = 0; c[j] != '\0'; j++) {
      int a = c[j] - 'a' + 1;
      if (x == 0)
        x = a;
      else if (y == 0 && a != x)
        y = a;
      else if (y != 0 && a != x && a != y) {
        less = false;
        break;
      }
    }
    if (less) {
      if (x != 0 && y != 0) {
        result[x][y] += j;
        result[y][x] += j;
      } else
        for (int k = 0; k < 27; k++) {
          result[x][k] += j;
          result[k][x] += j;
          result[x][x] -= j;
        }
    }
  }
  int max = 0;
  for (int i = 0; i < 27; i++) {
    for (int j = 0; j < 27; j++) {
      if (result[i][j] > max) {
        max = result[i][j];
      }
    }
  }
  cout << max;
  return 0;
}
