#include <bits/stdc++.h>
using namespace std;
const int MAX = 200010;
const int MOD = 1000000007;
const int INF = 1e8;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const long double EPS = 1e-7;
int main() {
  char c;
  string s, num;
  getline(cin, num);
  getline(cin, s);
  int res = 0, qt = 0;
  for (auto c : s) {
    if (c == ' ') {
      res = max(res, qt);
      qt = 0;
    } else {
      if (c >= 'A' and c <= 'Z') {
        qt++;
      }
    }
  }
  res = max(res, qt);
  cout << res << '\n';
  return 0;
}
