#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 30);
const int MX = 1e6 + 9;
int n, mx, sum;
string s;
int main() {
  cin >> n;
  getline(cin, s);
  getline(cin, s);
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == ' ') {
      mx = max(mx, sum);
      sum = 0;
      continue;
    }
    if (isupper(s[i])) sum++;
  }
  cout << max(mx, sum);
}
