#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::string NumberToString(T Number) {
  std::ostringstream ss;
  ss << Number;
  return ss.str();
}
long long gcd(long long a, long long b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
int main() {
  int n;
  string str;
  map<char, int> mp;
  while (cin >> n) {
    cin >> str;
    int mx = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
      if (str[i] >= 65 && str[i] <= 90) {
        mp.clear();
        if (mx <= cnt) {
          mx = cnt;
        }
        cnt = 0;
      } else if ((str[i] >= 97 && str[i] <= 122)) {
        if (mp[str[i]] == 0) {
          cnt++;
        }
        if (mx <= cnt) {
          mx = cnt;
        }
        mp[str[i]]++;
      }
    }
    printf("%d\n", mx);
    mp.clear();
  }
  return 0;
}
