#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
char c[maxn];
int main() {
  ios::sync_with_stdio(false);
  int n;
  int ans = 0;
  cin >> n;
  while (cin >> c) {
    int cnt = 0;
    for (int i = 0; i < strlen(c); i++) {
      if (c[i] >= 'A' && c[i] <= 'Z') {
        cnt++;
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}
