#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  int resMax = 0, len = 0;
  while (len < n) {
    cin >> s;
    len += s.size() + 1;
    int res = 0;
    for (char c : s)
      if (c >= 'A' && c <= 'Z') res++;
    resMax = max(res, resMax);
  }
  cout << resMax << endl;
  return 0;
}
