#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string arr[100];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long res[26][26];
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 26; j++) {
      res[i][j] = 0;
    }
  }
  for (int i = 0; i < 26; i++) {
    for (int j = i + 1; j < 26; j++) {
      for (int k = 0; k < n; k++) {
        bool b = true;
        for (int l = 0; l < arr[k].length(); l++) {
          if (arr[k][l] - 'a' != i && arr[k][l] - 'a' != j) {
            b = false;
            break;
          }
        }
        if (b) {
          res[i][j] += arr[k].length();
        }
      }
    }
  }
  long maxi = 0;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 26; j++) {
      maxi = max(maxi, res[i][j]);
    }
  }
  cout << maxi << endl;
}
