#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int ans = 0;
  string token;
  while (cin >> token) {
    int cur = 0;
    for (char c : token) {
      if (isupper(c)) cur++;
    }
    ans = max(ans, cur);
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
