#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, c;
  cin >> n;
  string sstr, str;
  stack<string> v;
  cin.ignore();
  getline(cin, str);
  istringstream is(str);
  while (is >> sstr) v.push(sstr);
  int vol = 0;
  while (!v.empty()) {
    c = 0;
    string s = v.top();
    n = s.size();
    for (i = 0; i < n; i++) {
      if (s[i] >= 65 && s[i] <= 90) c++;
    }
    if (c > vol) vol = c;
    v.pop();
  }
  cout << vol << endl;
  return 0;
}
