#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  char x;
  cin >> n;
  int c = 0, d = 0;
  for (i = 0; i <= n; i++) {
    x = getchar();
    if (x >= 'A' && x <= 'Z') c++;
    if (x == ' ' || i == n) {
      if (c > d) d = c;
      c = 0;
    }
  }
  cout << d;
  return 0;
}
