#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  cin.ignore();
  string arr;
  getline(cin, arr);
  int mx = 0;
  int cur = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == ' ') {
      mx = max(mx, cur);
      cur = 0;
      continue;
    }
    if (isupper(arr[i])) {
      cur++;
    }
  }
  mx = max(mx, cur);
  cout << mx;
  return 0;
}
