#include <bits/stdc++.h>
using namespace std;
int n;
int maxxnoize = -100000;
int main() {
  cin >> n;
  int noizeword = 0;
  string s;
  while (cin >> s) {
    for (int i = 0; i < s.length(); i++)
      if (isupper(s[i])) noizeword++;
    maxxnoize = max(maxxnoize, noizeword);
    noizeword = 0;
  }
  cout << maxxnoize;
  return 0;
}
