#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int count = 0, max = 0, i, m;
  cin >> m;
  getchar();
  getline(cin, s);
  s += ' ';
  for (i = 0; i <= m; i++) {
    if (s[i] >= 'A' && s[i] <= 'Z')
      count++;
    else if (s[i] == ' ') {
      if (count > max) {
        max = count;
      }
      count = 0;
    }
  }
  cout << max << endl;
  return 0;
}
