#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[201];
  int mx = 0, n, cnt;
  cin >> n;
  while (cin >> s) {
    cnt = 0;
    int len = strlen(s);
    for (int i = 0; i < len; i++) {
      if (s[i] >= 'A' && s[i] <= 'Z') cnt++;
    }
    mx = max(mx, cnt);
  }
  cout << mx;
}
