#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long bigmod(long long b, long long p, long long m) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    long long temp = bigmod(b, p / 2, m);
    return (temp * temp) % m;
  }
  return (bigmod(b, p - 1, m) * (b % m)) % m;
}
long long lcm(long long a, long long b) { return (a * b) / (gcd(a, b)); }
map<int, int> mm;
int all_divisors(int n) {
  if (mm[n]) return mm[n];
  int num = 0, sq = sqrt(n);
  for (int i = 1; i <= sq; i++) {
    if (n % i == 0) num++;
  }
  if (sq * sq == n)
    num = 2 * num - 1;
  else
    num *= 2;
  return (mm[n] = num);
}
bool is_prime(int number) {
  if (number < 2) return false;
  if (number == 2) return true;
  if (number % 2 == 0) return false;
  for (int i = 3; (i * i) <= number; i += 2)
    if (number % i == 0) return false;
  return true;
}
long long count_number_in_range_divisible_by_K(long long a, long long b,
                                               long long k) {
  long long ans = 0;
  if (a < 0 && b > 0)
    ans = (b / k) - (a / k) + 1;
  else
    ans = (max(abs(a), abs(b)) / k - min(abs(a), abs(b)) / k +
           (min(abs(a), abs(b)) % k == 0));
  return ans;
}
int n;
char ss, s[333];
int Max = 0, num = 0;
int main() {
  scanf("%d", &n);
  getchar();
  gets(s);
  for (int i = 0; i < strlen(s); i++) {
    if (s[i] == ' ') {
      Max = max(Max, num);
      num = 0;
    } else if (isupper(s[i]))
      num++;
  }
  printf("%d", max(Max, num));
  return 0;
}
