#include <bits/stdc++.h>
using namespace std;
int main() {
  iostream::sync_with_stdio(false);
  cin.tie(NULL);
  int n, ans = 0;
  string s;
  cin >> n >> s;
  unordered_map<char, int> letters;
  for (int i = 0; i < n; i++) {
    if ('A' <= s[i] && s[i] <= 'Z') {
      ans = (((ans) > (letters.size())) ? (ans) : (letters.size()));
      letters.clear();
    } else {
      letters[s[i]] = 0;
    }
  }
  ans = (((ans) > (letters.size())) ? (ans) : (letters.size()));
  cout << ans << '\n';
}
