#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
string s;
int n;
string x = "";
int ans = 0;
int y;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n;
  getline(cin, s);
  getline(cin, s);
  for (auto it : s) {
    x += it;
    if (it == ' ') {
      for (auto it : x) {
        if (it >= 'A' && it <= 'Z') y++;
      }
      ans = max(ans, y);
      y = 0;
      x = "";
    }
  }
  for (auto it : x) {
    if (it >= 'A' && it <= 'Z') y++;
  }
  ans = max(ans, y);
  y = 0;
  x = "";
  return cout << ans, 0;
}
