#include <bits/stdc++.h>
int main() {
  int n;
  scanf("%d", &n);
  int i, j, k, l;
  char word[100][1001];
  for (i = 0; i < n; i++) {
    scanf("%s", word[i]);
  }
  int max_length = 0;
  int counter[26];
  for (i = 0; i < 26; i++) {
    counter[i] = 0;
  }
  for (i = 0; i < n; i++) {
    j = 0;
    while (word[i][j] != '\0') {
      counter[word[i][j] - 'a']++;
      j++;
    }
  }
  for (i = 0; i < 26; i++) {
    for (j = 0; j < 26; j++) {
      int current_length = 0;
      for (k = 0; k < n; k++) {
        l = 0;
        int word_length = 0;
        while (word[k][l] != '\0') {
          if (word[k][l] == i + 'a' || word[k][l] == j + 'a') {
            word_length++;
          } else {
            word_length = 0;
            break;
          }
          l++;
        }
        current_length += word_length;
      }
      if (current_length > max_length) max_length = current_length;
    }
  }
  for (i = 0; i < 26; i++) {
    int current_length = 0;
    for (k = 0; k < n; k++) {
      l = 0;
      int word_length = 0;
      while (word[k][l] != '\0') {
        if (word[k][l] == i + 'a') {
          word_length++;
        } else {
          word_length = 0;
          break;
        }
        l++;
      }
      current_length += word_length;
    }
    if (current_length > max_length) max_length = current_length;
  }
  printf("%d\n", max_length);
  return 0;
}
