#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  while (cin >> N) {
    int sum = 0, mx = 0;
    getchar();
    while (N--) {
      char ch = getchar();
      if (ch == ' ') {
        sum = 0;
        continue;
      }
      if (ch >= 'A' && ch <= 'Z') sum++;
      mx = max(mx, sum);
    }
    cout << mx << endl;
  }
  return 0;
}
