#include <bits/stdc++.h>
using namespace std;
int n, Max;
string s;
int main() {
  cin >> n, cin.ignore();
  getline(cin, s);
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == ' ')
      Max = max(Max, cnt), cnt = 0;
    else if (s[i] <= 'Z')
      ++cnt;
  }
  Max = max(Max, cnt);
  cout << Max;
}
