#include <bits/stdc++.h>
using namespace std;
string nm[105];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> nm[i];
  int ans = -1;
  for (int i = 0; i < 26; i++) {
    for (int j = i + 1; j < 26; j++) {
      int val = 0;
      for (int k = 0; k < n; k++) {
        int l = nm[k].length();
        int k1 = 0;
        char ch1 = 'a' + i, ch2 = 'a' + j;
        for (int x = 0; x < l; x++) {
          if (nm[k][x] == ch1 || nm[k][x] == ch2)
            k1++;
          else
            break;
        }
        if (k1 == l) val += l;
      }
      ans = max(ans, val);
    }
  }
  cout << ans << "\n";
  return 0;
}
