#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, max = 0, c, i;
  cin >> n;
  string str;
  while (cin >> str) {
    c = 0;
    for (i = 0; i < str.length(); i++) {
      if (str[i] >= 'A' && str[i] <= 'Z') c++;
      if (c > max) max = c;
    }
  }
  printf("%d", max);
  return 0;
}
