#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, maxx = -1e9, cntt = 0;
  cin >> n;
  do {
    string s;
    int cnt = 0;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] <= 'Z' && s[i] >= 'A') cnt++;
    }
    maxx = max(maxx, cnt);
    cntt += s.length() + 1;
  } while (cntt <= n);
  cout << maxx;
  return 0;
}
