#include <bits/stdc++.h>
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,abm,mmx,avx,avx2,popcnt,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/STACK:36777216")
using namespace std;
const int MAXN = 2e5 + 1;
const long long inf = 1e9;
const long double EPS = 1e-4;
const long double PI = acos(-1);
int mod = (int)998244353;
const int MOD9 = 1000000009;
const int a228 = 18;
const long long MOD = 1000000007;
const int maxelem = 12000000;
const int fsconst = 12000;
signed main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  srand(time(NULL));
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  set<char> kek;
  s.push_back('A');
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] >= 'A' && s[i] <= 'Z') {
      ans = max(ans, (int)kek.size());
      kek.clear();
    } else {
      kek.insert(s[i]);
    }
  }
  cout << ans;
}
