#include <bits/stdc++.h>
using namespace std;
int arr[26][26];
int main() {
  ios_base::sync_with_stdio(0);
  int i, j, ans, n;
  string s[100];
  cin >> n;
  for (i = 0; i <= n - 1; i++) {
    cin >> s[i];
  }
  for (i = 0; i < n; i++) {
    int temp[26] = {0}, cnt = 0, k = 0;
    char ch[3];
    for (j = 0; j < s[i].length(); j++) {
      if (temp[s[i][j] - 'a']) {
        temp[s[i][j] - 'a']++;
      } else {
        cnt++;
        temp[s[i][j] - 'a']++;
        ch[k] = s[i][j];
        k++;
      }
      if (cnt > 2) break;
    }
    if (j == s[i].length()) {
      if (cnt == 1) {
        for (j = 0; j < 26; j++) {
          arr[ch[0] - 'a'][j] += s[i].length();
          if (j != ch[0] - 'a') arr[j][ch[0] - 'a'] += s[i].length();
        }
      } else {
        if (ch[0] > ch[1]) {
          char tempch = ch[0];
          ch[0] = ch[1];
          ch[1] = tempch;
        }
        arr[ch[0] - 'a'][ch[1] - 'a'] += s[i].length();
        arr[ch[1] - 'a'][ch[0] - 'a'] += s[i].length();
      }
    }
  }
  ans = 0;
  for (i = 0; i < 26; i++) {
    for (j = 0; j < 26; j++) {
      ans = max(ans, arr[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}
