#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c = 0, flag = 0;
  int max = -1;
  int fmax = -1;
  cin >> n;
  char ch[n];
  for (int i = 0; i < n + 1; i++) {
    scanf("%c", &ch[i]);
    if (ch[i] == ' ') {
      flag = 1;
      if (c > max) max = c;
      c = 0;
    }
    if (ch[i] >= 'A' && ch[i] <= 'Z') c++;
  }
  if (!flag) max = c;
  if (flag) {
    if (c > max) max = c;
  }
  cout << max;
  return 0;
}
