#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long m = 0;
  long long n;
  cin >> n;
  char k;
  long long p = 0;
  map<char, long long> ar;
  for (char u = 'A'; u <= 'Z'; u++) ar[u]++;
  string x;
  getline(cin, x);
  getline(cin, x);
  for (long long i = 0; i < n; i++) {
    k = x[i];
    if (ar[k] != 0) p++;
    if (k == ' ') {
      m = max(p, m);
      p = 0;
    }
  }
  m = max(p, m);
  cout << m << endl;
}
