#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, count = 0, max = 0;
  char *str;
  cin >> n;
  str = new char[n];
  scanf("%c", &str[0]);
  for (int i = 0; i < n; i++) {
    scanf("%c", &str[i]);
    if (str[i] == ' ') {
      if (count > max) {
        max = count;
        count = 0;
      }
      count = 0;
    } else if (isupper(str[i])) {
      count++;
      if (count > max) {
        max = count;
      }
    }
  }
  cout << max;
  return 0;
}
