#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int main() {
  cin >> n;
  cin.ignore();
  getline(cin, s);
  int _m = 0;
  int dem = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i + 1] == ' ' || s[i + 1] == '\0') {
      if ('A' <= s[i] and s[i] <= 'Z') {
        dem++;
      }
      _m = max(_m, dem);
      dem = 0;
    } else {
      if ('A' <= s[i] and s[i] <= 'Z') {
        dem++;
      }
    }
  }
  printf("%d", _m);
  return 0;
}
