#include <bits/stdc++.h>
int main(void) {
  int n, i, c = 0, x;
  int j, k, copy = 0;
  int arr[200];
  char string[300], ch;
  scanf("%d", &n);
  scanf("%s", string);
  for (i = 0; i < 50; i++) {
    arr[i] = 0;
  }
  for (i = 0; i < n; i++) {
    x = string[i] - 'a';
    if (islower(string[i]) && c == 0) {
      ch = string[i];
      c++;
      arr[x]++;
    } else if (string[i] != ch && islower(string[i]) && arr[x] == 0) {
      c++;
      arr[x]++;
    } else if (isupper(string[i])) {
      if (c > copy) {
        copy = c;
      }
      for (j = 0; j < 50; j++) {
        arr[j] = 0;
      }
      c = 0;
    }
  }
  if (c > copy) {
    printf("%d", c);
  } else {
    printf("%d", copy);
  }
  return 0;
}
