#include <bits/stdc++.h>
using namespace std;
int nCaps(string s, int n) {
  int ncap = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] < 'a' || s[i] > 'z') {
      ncap++;
    }
  }
  return ncap;
}
int main() {
  int n, i = 0, max = 0;
  char c;
  string s;
  cin >> n;
  do {
    cin >> s;
    int tamp = nCaps(s, s.length());
    if (tamp > max) max = tamp;
    i += (s.length() + 1);
  } while (i < n);
  cout << max << endl;
  return 0;
}
