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