#include <bits/stdc++.h>
using namespace std;
bool check(char x) {
  if ((x >= 'a') && (x <= 'z'))
    return 1;
  else
    return 0;
}
int main() {
  int n;
  string s;
  cin >> n >> s;
  int hash[26];
  memset(hash, 0, sizeof(hash));
  vector<vector<int> > vp;
  vector<int> vx;
  for (int i = 0; i < n; i++) {
    if (check(s[i]) && (hash[s[i] - 'a'] == 0)) {
      vx.push_back(i);
      hash[s[i] - 'a'] = 1;
    } else if (!check(s[i])) {
      if (vx.size() != 0) vp.push_back(vx);
      vx.clear();
      memset(hash, 0, sizeof(hash));
    }
  }
  if (vx.size() != 0) vp.push_back(vx);
  int maxi = 0;
  int l = vp.size();
  for (int i = 1; i < l; i++) {
    if (vp[maxi].size() < vp[i].size()) maxi = i;
  }
  if (l == 0)
    cout << 0 << endl;
  else
    cout << vp[maxi].size() << endl;
}
