#include <bits/stdc++.h>
using namespace std;
long long int a[100001];
int main() {
  ios::sync_with_stdio(false);
  ;
  cin.tie(0);
  ;
  long long int i, j, n, x, y, ans = 0, f = 0, cnt = 0, l, got = 0;
  char ch;
  string s;
  cin >> l;
  while (1) {
    if (got >= l) break;
    cin >> s;
    got += s.length();
    cnt = 0;
    for (i = 0; i < s.length(); i++) cnt += (s[i] >= 'A' && s[i] <= 'Z');
    ans = max(ans, cnt);
    got++;
    if (got >= l) break;
  }
  cout << ans;
  return 0;
}
