#include <bits/stdc++.h>
using namespace std;
long arr[500];
int main() {
  int useless;
  cin >> useless;
  int maxx = 0;
  string word;
  while (cin >> word) {
    int cnt = 0;
    for (int i = 0; i < word.length(); i++)
      if (word[i] >= 'A' && word[i] <= 'Z') cnt++;
    if (cnt > maxx) maxx = cnt;
  }
  cout << maxx;
}
