#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, mx = 0;
  cin >> n;
  string s;
  while (cin >> s) {
    int ct = 0;
    for (int i = 0; i < s.length(); i++)
      if (isupper(s[i])) ct++;
    mx = max(ct, mx);
  }
  cout << mx << '\n';
  return 0;
}
