#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const int N = 1000 + 10;
const int M = 5000 + 10;
int main(void) {
  int n;
  scanf("%d", &n);
  getchar();
  string s;
  getline(cin, s);
  int cnt = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] >= 'A' && s[i] <= 'Z') {
      cnt++;
    } else if (s[i] == ' ') {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);
  printf("%d", ans);
  return 0;
}
