#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  scanf("\n");
  char s[250];
  cin.getline(s, 256);
  int maxc = 0, count = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == ' ') {
      maxc = max(maxc, count);
      count = 0;
    } else if (isupper(s[i]))
      count++;
  }
  maxc = max(maxc, count);
  cout << maxc;
  return 0;
}
