#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long mul(long long a, long long b) {
  long long q = (long double)(a)*b / MOD;
  long long result = a * b - q * MOD;
  while (result < 0) result += MOD;
  while (result >= MOD) result -= MOD;
  return result;
}
long long pow(long long a, long long n) {
  if (n == 0) return 1;
  if (n % 2 == 0) {
    long long tmp = pow(a, n / 2);
    return mul(tmp, tmp);
  } else
    return mul(a, pow(a, n - 1));
}
long long gcd(long long a, long long b) {
  while (a > 0 && b > 0) {
    if (b > a) swap(a, b);
    a %= b;
  }
  return a + b;
}
long long lcm(long long a, long long b) {
  long long t = gcd(a, b);
  if (a % t == 0)
    return a / t * b;
  else
    return b / t * a;
}
int main() {
  int n, m;
  vector<vector<int> > a(26, vector<int>(26, 0));
  string s;
  char x, y;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    x = y = 0;
    int j;
    m = (int)s.size();
    for (j = 0; j < m; ++j)
      if (x == 0)
        x = s[j];
      else if (s[j] != x)
        if (y == 0)
          y = s[j];
        else if (s[j] != y)
          break;
    if (j == m) {
      x -= 97;
      if (y == 0)
        for (int k = 0; k < 26; ++k) {
          if (k != x) {
            a[x][k] += m;
            a[k][x] += m;
          }
        }
      else {
        y -= 97;
        a[x][y] += m;
        a[y][x] += m;
      }
    }
  }
  m = 0;
  for (int i = 0; i < 26; ++i)
    for (int j = 0; j < 26; ++j)
      if (a[i][j] > m) m = a[i][j];
  cout << m;
  return 0;
}
