#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
long long int gcd(long long int a, long long int b) {
  long long int r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
bool prime[10001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  cin.ignore();
  string str;
  getline(cin, str);
  int ans = 0, c = 0;
  for (long long int i = 0; i <= str.size() - 1; i++) {
    if (str[i] >= 'A' && str[i] <= 'Z') {
      c++;
    }
    if (str[i] == ' ' || i == str.size() - 1) {
      if (c >= ans) ans = c;
      c = 0;
    }
  }
  cout << ans;
  return 0;
}
