#include <bits/stdc++.h>
using namespace std;
long long int binpow(long long int a, long long int b) {
  a %= 1000000007;
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  long long int cr, nn, i, ans = 0;
  string s;
  cr = 0;
  while (cin >> s) {
    cr = 0;
    nn = s.length();
    for (i = 0; i < nn; i++)
      if (s[i] - 'a' < 0) {
        cr++;
      }
    ans = max(ans, cr);
  }
  cout << ans;
}
