#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  int c = 0;
  string s;
  cin.ignore();
  getline(cin, s);
  for (int i = 0; i < n; i++) {
    if (s[i] <= 'Z' && s[i] >= 'A')
      c++;
    else if (s[i] == ' ') {
      ans = max(c, ans);
      c = 0;
    }
  }
  ans = max(ans, c);
  cout << ans;
  return 0;
}
