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