#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> f;
  f.push_back(-1);
  for (int i = 0; i < n; i++)
    if (s[i] >= 'A' && s[i] <= 'Z') f.push_back(i);
  f.push_back(n);
  int ans = 0;
  for (int i = 0; i < f.size() - 1; i++) {
    vector<bool> lol(26, 0);
    int t = 0;
    for (int j = f[i] + 1; j < f[i + 1]; j++) {
      if (!lol[s[j] - 'a']) t++, lol[s[j] - 'a'] = true;
    }
    ans = max(t, ans);
  }
  cout << ans;
  return 0;
}
