#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c = 0, res = 0, flag = 0;
  scanf("%d\n", &n);
  string s;
  getline(cin, s);
  for (int i = 0; i < (n); i++) {
    if (s[i] >= 'A' && s[i] <= 'Z') {
      c++;
    }
    if (s[i] == ' ' || i == n - 1) {
      flag = 1;
      if (c > res) res = c;
      c = 0;
    }
  }
  (flag == 0) ? cout << c << endl : cout << res << endl;
  return 0;
}
