#include <bits/stdc++.h>
using namespace std;
bool vis[26] = {false};
void setfalse() {
  for (int i = 0; i < 26; i++) vis[i] = false;
}
int main() {
  int n;
  cin >> n;
  string x;
  cin >> x;
  int a[n];
  if (x[0] >= 'a' && x[0] <= 'z') {
    vis[x[0] - 'a'] = true;
    a[0] = 0;
  } else
    a[0] = -1;
  for (int i = 1; i < n; i++) {
    if (x[i] >= 'A' && x[i] <= 'Z') {
      a[i] = -1;
      setfalse();
    } else {
      if (x[i] == x[i - 1]) {
        a[i] = a[i - 1];
      } else if (vis[x[i] - 'a'] == false) {
        a[i] = a[i - 1] + 1;
      } else {
        a[i] = a[i - 1];
      }
      vis[x[i] - 'a'] = true;
    }
  }
  int mx = *max_element(a, a + n);
  cout << mx + 1 << "\n";
}
