#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, j, k, w, l, count = 0, max = INT_MIN, min = INT_MAX;
  cin >> n;
  cin.ignore();
  string s;
  getline(cin, s);
  for (i = 0; i < n; i++) {
    if (s[i] >= 'A' && s[i] <= 'Z') {
      count++;
    } else if (s[i] == ' ') {
      if (count >= max) {
        max = count;
      }
      count = 0;
    }
  }
  if (max < count) {
    max = count;
  }
  cout << max << "\n";
  return 0;
}
