#include <bits/stdc++.h>
using namespace std;
long long int n, m, a, b, sum = 0, c, mx, mn = 1e18, cnt = 0, ans, temp, ff, tt;
vector<int> v, w;
set<char> st;
string s, g;
map<string, long long> mp;
pair<string, int> pr[10000];
int main() {
  cin >> n;
  getline(cin, s);
  getline(cin, s);
  for (int i = 0; i < s.size(); i++) {
    if (s[i] >= 'A' && s[i] <= 'Z')
      cnt++;
    else if (s[i] == ' ') {
      mx = max(cnt, mx);
      cnt = 0;
    }
  }
  if (mx >= cnt)
    cout << mx;
  else
    cout << cnt;
}
