#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n, c[26][26] = {0}, m;
  char ch1 = 'A', ch2 = 'A';
  string a[100];
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) {
    ch1 = a[i][0];
    for (j = 1; j < a[i].size(); j++) {
      if (a[i][j] != ch1) {
        if (ch2 == 'A') ch2 = a[i][j];
      }
      if (a[i][j] != ch1) {
        if (a[i][j] != ch2) {
          ch1 = 'A';
          ch2 = 'A';
          break;
        }
      }
    }
    if (ch1 != ch2) {
      if (ch2 != 'A') {
        c[(int)ch1 - 97][(int)ch2 - 97] += a[i].size();
        c[(int)ch2 - 97][(int)ch1 - 97] += a[i].size();
      } else {
        c[(int)ch1 - 97][(int)ch1 - 97] += a[i].size();
      }
    }
    ch1 = 'A';
    ch2 = 'A';
  }
  for (i = 0; i < 26; i++) {
    for (j = i + 1; j < 26; j++) {
      c[i][j] = c[i][j] + c[j][j] + c[i][i];
    }
  }
  m = 0;
  for (i = 0; i < 26; i++) {
    for (j = 0; j < 26; j++) {
      if (c[i][j] > m) m = c[i][j];
    }
  }
  cout << m;
}
