#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  int n;
  cin >> n;
  cin.get();
  getline(cin, s);
  int p1 = 0, p2;
  int ans = 0;
  while ((p2 = s.find(' ', p1)) != -1) {
    int tmp = 0;
    for (int i = p1; i < p2; i++) {
      if (s[i] >= 'A' && s[i] <= 'Z') {
        tmp++;
      }
    }
    ans = max(tmp, ans);
    p1 = p2 + 1;
  }
  int tmp = 0;
  for (int i = p1; i < n; i++)
    if (s[i] >= 'A' && s[i] <= 'Z') {
      tmp++;
    }
  ans = max(ans, tmp);
  cout << ans << endl;
  return 0;
}
