#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[500];
  int n, i, j, k, l = -1;
  int num[500], top = 0;
  cin >> n;
  cin.get();
  cin.get(a, n + 1);
  for (i = 0; i < n; i++) {
    if (a[i] == ' ') {
      if (top > l) l = top;
      top = 0;
    }
    if (a[i] >= 'A' && a[i] <= 'Z') {
      top++;
    }
    if (i == n - 1) {
      if (top > l) l = top;
    }
  }
  cout << l;
}
