#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, mi = -1, x = 0, i, z = 0;
  cin >> n;
  string s;
  while (cin >> s) {
    for (i = 0; i < s.length(); i++) {
      if (65 <= s[i] && s[i] <= 90) x++;
    }
    mi = max(mi, x);
    x = 0;
  }
  mi = max(mi, x);
  cout << mi << endl;
  return 0;
}
