#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
long long int cnt[200005];
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    long long int n, b, i = 0, m = 0, maxm = 0, k = 0, j = 0, flag = 0, x,
                        summ = 0, q = 0;
    cin >> n;
    string s;
    long long int temp = n;
    while (temp > 0) {
      string s1;
      cin >> s1;
      s += s1;
      s += ' ';
      temp = temp - s1.length() - 1;
    }
    long long int cnt = 0;
    long long int mxcnt = 0;
    for (i = 0; i < n; i++) {
      if (s[i] == ' ')
        mxcnt = max(cnt, mxcnt), cnt = 0;
      else if (s[i] >= 'A' && s[i] <= 'Z')
        cnt++, mxcnt = max(mxcnt, cnt);
    }
    cout << mxcnt << endl;
    ;
  }
}
