#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 + 7;
set<char> c;
string s;
int n, a[120];
int main() {
  cin >> n;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (int(s[i]) <= int('Z')) {
      int v = c.size();
      ans = max(ans, v);
      while (!c.empty()) {
        c.erase(*c.begin());
      }
      continue;
    }
    c.insert(s[i]);
  }
  int v = c.size();
  ans = max(ans, v);
  cout << ans;
}
