#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 100;
string s;
long long f() {
  long long ans = 0;
  for (auto c : s) {
    if (c >= 'A' && c <= 'Z') ans++;
  }
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  long long maxi = 0;
  while (cin >> s) {
    maxi = max(maxi, f());
  }
  cout << maxi << "\n";
  return 0;
}
