#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, ans = 0;
  string s;
  cin >> n;
  while (cin >> s) {
    int cnt = 0;
    for (int i = 0; i < s.length(); ++i) {
      if (s[i] >= 'A' && s[i] <= 'Z') {
        ++cnt;
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}
