#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  scanf("%d ", &n);
  getline(cin, s);
  int cnt = 0, mx = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == ' ') {
      mx = max(mx, cnt);
      cnt = 0;
    }
    if (s[i] >= 'A' && s[i] <= 'Z') cnt++;
  }
  cout << max(mx, cnt) << endl;
  return 0;
}
