#include <bits/stdc++.h>
using namespace std;
string s;
vector<int> aux;
int a[30], n;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> s;
  s = "x" + s;
  aux.push_back(0);
  for (int i = 1; i <= n; i++) {
    if (s[i] >= 'A' and s[i] <= 'Z') aux.push_back(i);
  }
  aux.push_back(n + 1);
  int ans = 0;
  for (int i = 0; i < aux.size() - 1; i++) {
    int l = aux[i];
    int r = aux[i + 1];
    int _count = 0;
    for (int j = 0; j < 26; j++) a[j] = 0;
    for (int j = l + 1; j < r; j++) {
      a[s[j] - 'a'] = 1;
    }
    for (int j = 0; j < 26; j++) {
      if (a[j]) _count++;
    }
    ans = max(ans, _count);
  }
  cout << ans << "\n";
  return 0;
}
