#include <bits/stdc++.h>
using namespace std;
char b[1000];
int n;
int main() {
  int t;
  while (cin >> t) {
    getchar();
    int num = 0, maxnum = 0;
    cin.getline(b, sizeof(b));
    char c;
    for (int i = 0; i < t; i++) {
      if (b[i] >= 'A' && b[i] <= 'Z')
        num++;
      else if (b[i] == ' ') {
        if (maxnum < num) maxnum = num;
        num = 0;
      }
    }
    if (maxnum < num) maxnum = num;
    printf("%d\n", maxnum);
  }
  return 0;
}
