#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int cnt = 0;
  string s;
  int m = 0;
  while (cin >> s) {
    for (int i = 0; i < s.size(); i++)
      if (s[i] >= 'A' && s[i] <= 'Z') cnt++;
    m = max(m, cnt);
    cnt = 0;
  }
  printf("%d", m);
  return 0;
}
