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