#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  long long res = 1;
  while (y--) {
    res *= x;
  }
  return res;
}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
bool sortbysec(const pair<long long, long long>& a,
               const pair<long long, long long>& b) {
  return (a.second < b.second);
}
void solve() {
  long long n;
  cin >> n;
  long long ans = 0, cnt = 0;
  std::string s;
  std::getline(std::cin >> std::ws, s);
  for (long long i = 0; i < n; i++) {
    if (s[i] >= 'A' && s[i] <= 'Z') {
      cnt++;
    }
    if (s[i] == ' ') {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);
  cout << ans;
}
int main() {
  fast();
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
}
