#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, count = 0, max = 0, flag = 0;
  cin >> n;
  char ch[n + 2];
  cin.getline(ch, n + 2, '\0');
  for (int i = 0; i <= n; i++) {
    if (ch[i] != ' ') {
      if (ch[i] >= 'A' && ch[i] <= 'Z') {
        count++;
      }
    } else if (ch[i] == ' ') {
      flag = 1;
      if (max < count) {
        max = count;
      }
      count = 0;
    }
  }
  if (flag == 0 || count > max)
    cout << count << endl;
  else
    cout << max << endl;
  return 0;
}
