#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  int k = 0, m = 0;
  while (cin >> s) {
    for (int i = 0; i < s.size(); i++) {
      if (s[i] >= 'A' and s[i] <= 'Z') k++;
    }
    if (k > m) {
      m = k;
      k = 0;
    } else
      k = 0;
  }
  cout << m;
  return 0;
}
