#include <bits/stdc++.h>
using namespace std;
const int N = 210;
string s;
int n, cur = 0, res = 0;
int main() {
  scanf("%d", &n);
  while (cin >> s) {
    cur = 0;
    for (int i = (0), _b = (s.size()); i < _b; ++i)
      if (s[i] >= 'A' && s[i] <= 'Z') cur++;
    res = max(res, cur);
  }
  cout << res << endl;
  return 0;
}
