#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 256;
char s[MAX_N];
int main() {
  int n;
  scanf("%d", &n);
  while (getchar() != '\n')
    ;
  fgets(s, MAX_N, stdin);
  int maxv = 0;
  for (int i = 0; i < n;) {
    while (s[i] == ' ') i++;
    if (i >= n) break;
    int v = 0;
    while (i < n && s[i] > ' ') {
      if (s[i] >= 'A' && s[i] <= 'Z') v++;
      i++;
    }
    if (maxv < v) maxv = v;
  }
  printf("%d\n", maxv);
  return 0;
}
