#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string c, temp;
  int C = 0;
  vector<int> v;
  getline(cin, temp);
  getline(cin, c);
  for (int i = 0; i < n; i++) {
    if (isspace(c[i])) {
      v.push_back(C);
      C = 0;
    } else if (isupper(c[i])) {
      C++;
    }
  }
  v.push_back(C);
  sort(v.begin(), v.end());
  cout << v[v.size() - 1];
}
