#include <bits/stdc++.h>
using namespace std;
string s;
int n, mx;
int volume(string t, int sz) {
  int res = 0;
  for (int i = 0; i < sz; i++)
    if (t[i] >= 'A' && t[i] <= 'Z') res++;
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  while (true) {
    cin >> s;
    int sz = s.size();
    mx = max(mx, volume(s, sz));
    if (n == sz) return cout << mx, 0;
    n -= sz + 1;
  }
  return 0;
}
