#include <bits/stdc++.h>
using namespace std;
int n, ans = 0;
string s;
int main() {
  scanf("%d", &n);
  getchar();
  getline(cin, s);
  int d = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == ' ' || s[i] == '\0') {
      ans = max(ans, d);
      d = 0;
    } else {
      if (s[i] == (int)toupper(s[i])) d++;
    }
  }
  ans = max(ans, d);
  cout << ans << endl;
  return 0;
}
