#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r = 0, m = 0;
  string s;
  cin >> n;
  while (!cin.eof()) {
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
      if (int(s[i]) > 64 && int(s[i]) < 91) {
        r++;
      }
    }
    if (r > m) {
      m = r;
    }
    r = 0;
  }
  cout << m;
  return 0;
}
