#include <bits/stdc++.h>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  std::string s;
  while (cin >> s) {
    int cur = 0;
    for (char c : s) {
      if (isupper(c)) {
        ++cur;
      }
    }
    ans = std::max(ans, cur);
  }
  cout << ans << endl;
}
