#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  cin.ignore();
  string s;
  getline(cin, s);
  s = s + ' ';
  int out = 0;
  for (int i = (0); i < (n); i++) {
    int tr = 0;
    while (s[i] != ' ') {
      tr += (s[i] >= 'A' && s[i] <= 'Z');
      i++;
    }
    out = max(out, tr);
  }
  cout << out << endl;
  return 0;
}
