#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int main() {
  int n, len, maxm, i, num;
  char a[maxn];
  while (scanf("%d", &n) != EOF) {
    getchar();
    gets(a);
    maxm = -1;
    len = strlen(a);
    num = 0;
    for (i = 0; i < len; i++) {
      if (a[i] != ' ') {
        if (a[i] >= 'A' && a[i] <= 'Z') num++;
      } else {
        maxm = max(num, maxm);
        num = 0;
      }
    }
    maxm = max(maxm, num);
    printf("%d\n", maxm);
  }
  return 0;
}
