#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, count = 0, max = 0;
  char line;
  cin >> n;
  n++;
  while (n--) {
    char temp;
    scanf("%c", &temp);
    if (temp == ' ') {
      if (count > max) max = count;
      count = 0;
    } else if (temp >= 'A' && temp <= 'Z')
      count++;
  }
  if (count > max) max = count;
  cout << max;
  return 0;
}
