#include <bits/stdc++.h>
using namespace std;
int vol(string s) {
  int v = 0;
  for (auto e : s) {
    if (isupper(e)) v++;
  }
  return v;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  getline(cin, s);
  getline(cin, s);
  istringstream ss(s);
  int mx = 0;
  while (ss >> s) {
    mx = max(mx, vol(s));
  }
  cout << mx << endl;
  return 0;
}
