#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 6, mod = 1e9 + 7;
const long long OO = (long long)1e18;
int main() {
  int n, ans = 0;
  cin >> n;
  string s, z;
  cin.get();
  getline(cin, s);
  stringstream ss(s);
  while (ss >> s) {
    int temp = 0;
    for (auto i : s) temp += isupper(i);
    ans = max(temp, ans);
  }
  cout << ans;
}
