#include <bits/stdc++.h>
using namespace std;
const long maxn = 100005;
void fileio() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
string s;
stack<char> se;
int n;
int ans = 0;
vector<int> pos;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  cin >> s;
  s = 'Z' + s;
  s = s + 'Z';
  for (int i = 0; i < (int)s.length(); i++)
    if (s[i] >= 'A' && s[i] <= 'Z') pos.push_back(i);
  for (int i = 1; i < (int)pos.size(); i++) {
    int lua[250] = {0};
    int cnt = 0;
    for (int j = pos[i - 1] + 1; j < pos[i]; j++)
      if (lua[s[j]] == 0) cnt++, lua[s[j]]++;
    ans = max(ans, cnt);
  }
  cout << ans;
  return 0;
}
