#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
const long long lim = 1e6 + 100;
template <typename T1>
void printIt(T1 t1) {
  cout << t1 << " )" << endl;
}
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) {
  cout << t1 << " , ";
  printIt(t2...);
}
long long powP(long long x, long long y) {
  long long ans = 1, po = x % mod;
  while (y > 0) {
    if (y & 1) ans = ans * po % mod;
    y >>= 1;
    po = po * po % mod;
  }
  return ans;
}
long long findGcd(long long a, long long b) {
  while (a != 0) {
    long long temp = b % a;
    b = a;
    a = temp;
  }
  return b;
}
long long Array[lim], BArray[lim], dp[lim];
pair<long long, long long> P[lim];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long int T, i, p, j, l, e, r, b, c, k, m, q, a, d, w, x, y, u, v, z, t,
      curr, prev, sum = 0, val, temp, countA = 0, indicator = 0, pos, h, minA,
                  maxA, type, n, ans = 0, left, right;
  string A, B, C;
  A = "Yes", B = "No", C = "2";
  long long Co[50][50] = {};
  cin >> n;
  for (long long int i = (1); i <= (n); ++i) {
    cin >> A;
    set<char> S;
    for (auto j : A) {
      S.insert(j);
    }
    if (S.size() == 2) {
      auto it = S.begin();
      char a = *it;
      it++;
      char b = *it;
      Co[a - 'a'][b - 'a'] += A.size();
      Co[b - 'a'][a - 'a'] += A.size();
    }
    if (S.size() == 1) {
      char a = *S.begin();
      for (long long int j = (0); j <= (26); ++j) {
        Co[a - 'a'][j] += A.size();
        Co[j][a - 'a'] += A.size();
      }
      Co[a - 'a'][a - 'a'] -= A.size();
    }
  }
  ans = 0;
  for (long long int i = (0); i <= (30); ++i)
    for (long long int j = (0); j <= (30); ++j) ans = max(ans, Co[i][j]);
  cout << ans << endl;
  return 0;
}
