#include <bits/stdc++.h>
int dx[] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[] = {1, 1, 0, -1, -1, -1, 0, 1};
using namespace std;
int main() {
  string x, y;
  map<char, bool> check;
  int cnt = 0, mx = -1, n;
  cin >> n >> x;
  y += x[0];
  for (int i = 1; i < x.size(); i++) {
    if (x[i] == y[y.size() - 1])
      continue;
    else
      y += x[i];
  }
  for (int i = 0; i < y.size(); i++) {
    if (islower(y[i])) {
      if (!check[y[i]]) {
        ++cnt;
        check[y[i]] = 1;
      }
    } else {
      cnt = 0;
      check.clear();
    }
    mx = max(cnt, mx);
  }
  cout << mx << endl;
}
