#include <stdio.h>
#include <string.h>

int main()
{
    char s[500];
    int n,ans=0,cnt=0;
    scanf("%d ",&n);
    fgets(s,sizeof(s),stdin);
    for(int i=0;i<n;i++)
    {
        int k=s[i]-'A';
        if(s[i]==' ')
        {
            if(ans<cnt)
                ans=cnt;
            cnt=0;
            continue;
        }
        if(k>=0 && k<=25)
            cnt++;
    }
    if(ans<cnt)
        ans=cnt;
    printf("%d",ans);
    return 0;
}

#include <iostream>
#include <cctype>
#include <stdio.h>
using namespace std;

int main()
{
    int n,count=0,stro=0;
    char a[201]={0};
    cin >> n;
    getchar();
    for(int i=0;i<n;i++){
        scanf("%c",&a[i]);
    }
    for(int i=0;i<n+1;i++){
        if(isupper(a[i]))count++;
        if(a[i] == ' '|| a[i] == '\0'){
            stro=max(count,stro);
            count = 0;
        }
    }
    cout << stro;
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int n;
    int i,t,max=0;
    char a[300];
    scanf("%d",&n);
    getchar();
    gets(a);
    for(i=0; i<n; i++)
    {
        t=0;
        while(a[i]!=32&&i<n)
        {
            if(a[i]>=65&&a[i]<=90)
            {
                t++;
            }
            i++;
        }
        if(t>=max)
            max=t;
    }
    printf("%d\n",max);
    return 0;
}

#include<bits/stdc++.h>
#define dout if(debug) cout<<" "

using namespace std;

int debug = 1;

typedef unsigned long long int ulli;
typedef unsigned int ui;
typedef pair<int,int> mp;
typedef vector<vector<int> > matrix;

const int mod = 1e9+7;

bool is_big(char a){
    if (a >= 'A' and a <= 'Z') return true; return false;
}

void solve(){
    int n;
    cin>>n;
    string str;
    getline(cin,str);
    getline(cin,str);
    int maxx = 0,now = 0;
    for(int i=0;i< (int)str.length();i++){
        //cout << str[i] << endl;
        if(str[i] == 32){
            maxx = max(maxx , now);
            now = 0;
        }
        if(is_big(str[i])){
            now ++;
        }
    }
    maxx = max(maxx,now);
    cout << maxx << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--)solve();
}
// 4315448 unique_id

#include<bits/stdc++.h>
using namespace std;

//io
#define sf(x) scanf("%d",&x);
#define sf2(x,y) scanf("%d %d",&x,&y);
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z);
#define pf(x) printf("%d",x);
#define pf2(x,y) printf("%d %d",x,y);
#define pf3(x,y,z) printf("%d %d %d",x,y,z);
#define sfl(x) scanf("%lld",&x);
#define sfl2(x,y) scanf("%lld %lld",&x,&y);
#define sfl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z);
#define pfl(x) printf("%lld",x);
#define pfl2(x,y) printf("%lld %lld",x,y);
#define pfl3(x,y,z) printf("%lld %lld %lld",x,y,z);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//basic
#define pb push_back
#define ll long long
#define ld long double

#define mp make_pair
#define fi first
#define se second
#define mod 1000000007LL

//typedefs
#define pii pair<int,int>
#define pll pair<ll,ll>
#define Vpii vector<pii>
#define Vpll vector<pll>
#define Vll vector<ll>
#define Vi vector<int>
#define Vc vector<char>
#define Mii map<int,int>
#define Si  set<int>
#define Sl set<ll>
//functions
#define all(c) c.begin(),c.end()
#define fill(c,val) memset(c,val,sizeof(c))
#define f(i,j,n)    for(ll i=j;i<n;i++)

//misc
#define bitcount __builtin_popcount
#define next_string next_permutation

int main(){
int n;
cin>>n;
char ch;
ch =getchar();
string s;
getline(cin,s);
//24cout<<s;

int mx=0,cnt=0;
for(int i=0;i<n;i++){
//cout<<s[i];

if(s[i]==' ')
    cnt=0;
   else if(s[i]>='A' && s[i]<='Z')
    {

        cnt++;
          if(cnt>mx)
            mx=cnt;
    }

}
cout<<mx;
//cout<<"HAPPY CODING";
}

#include <stdio.h>

int N;

int main(int argc, char* argv[])
{
//	freopen("input.txt", "r", stdin);
	scanf("%d ", &N);
	int maxv = 0;
	int sum = 0;
	for(int i=0;i<N;i++) {
		char ch;
		scanf("%c", &ch);
		if (ch >= 'A' && ch <= 'Z') sum += 1;
		if (ch == ' ' || i == N-1) {
			if (maxv < sum)
				maxv = sum;
 			sum = 0;
		}
	}
	printf("%d\n", maxv);
	return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main()
{
string s;
int n,i,j,max=0,k=0;
cin>>n;
getline(cin,s);
getline(cin,s);
for(i=0;i<n;i++)
{
if(s[i]==' ')
{
if(k>max)max=k;
k=0;
}
else
{
if(s[i]<='Z'&&s[i]>='A')
{
k++;

}
}
}
if(k&&k>max)max=k;
cout<<max;
}

#include<bits/stdc++.h>
using namespace std;
int main ()
{
    char str[201];
    int n;
    int i;
    const char * split = " ";
    cin>>n;
    getchar();
    gets(str);
    char * p;
    p = strtok (str,split);
    int max=0;
    while(p!=NULL)
    {
        int sum=0;
        for(i=0; i<strlen(p); i++)
            if(p[i]>='A'&&p[i]<='Z')
                sum++;
        if(sum>max)
            max=sum;
        p = strtok(NULL,split);
    }
    cout<<max<<endl;
}

#include<bits/stdc++.h>

using namespace std;

using INT = long long;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n;
	cin >> n;
	string a;
	int ans = 0;

	while(cin >> a) {
		int cnt = 0;
		for(int i=0; i<a.size(); i++) {
			if(a[i] >= 'A' and a[i] <= 'Z') cnt++;
		}
		ans = max(ans, cnt);
	}

	cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
int main ()
{
    char str[201];
    int n;
    int i;
    const char * split = " ";
    cin>>n;
    getchar();
    gets(str);
    /*for(i=0; i<n; i++)
    {
        scanf("%c",&str[i]);
        //cout<<str[i];
    }*/
    char * p;
    p = strtok (str,split);
    int max=0;
    while(p!=NULL)
    {
        //cout<<p<<endl;
        int sum=0;
        for(i=0; i<strlen(p); i++)
            if(p[i]>='A'&&p[i]<='Z')
                sum++;
        if(sum>max)
            max=sum;
        p = strtok(NULL,split);
    }
    cout<<max<<endl;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int t=2;
	while(t--)
	{
	string s;
	getline(cin,s);
	int l=n;
	int c=0;
	int r=0;
	for(int i=0;i<l;i++)
	{
		if(s[i]>=65&&s[i]<=90)
		{
			c++;
		}
		else if(s[i]==' ')
		{
			r=max(r,c);
			c=0;
		}
		if(i==l-1&&t==0)
		{
			cout<<max(c,r);
		}
	}
  }

}

/* ********************************************* */
/*     100 codeforces problem                    */
/*     Bulbasaur Sabo                            */
/*     Kazakh-British TU 5, Team Sorry           */
/*	   Problem A                                 */
/* ********************************************* */
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 100;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const double pi = acos(-1);

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <pii> vpi;
typedef vector <pll> vpl;

#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) int(a.size())
#define pb push_back
#define mp make_pair
#define file "A"

int main(){
/*	#ifndef ONLINE_JUDGE
		freopen(file".in", "r", stdin);
		freopen(file".out", "w", stdout);
   	#endif  */

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, mx = 0, cur = 0;
	cin >> n;
	string s;
	getline(cin, s);
	getline(cin, s);
	s += " ";
	for(int i = 0; i < s.size(); i++){
		if(isalpha(s[i])){
			if(isupper(s[i])) cur++;
			else continue;
		}
		else{
			mx = max(mx, cur);
			cur = 0;
		}
	}
	cout << max(mx, cur);
	#ifndef ONLINE_JUDGE
        fprintf(stderr, "Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
	return 0;
}

#include<iostream>
#include<cctype>
#include<algorithm>

using namespace std;

main() {

	int n;
	int m = 0;
	string s;
	cin>>n;
	cin.ignore();
	getline(cin,s);
	int licz = 0;
	for(int i = 0; i < s.size(); i++) {

  	  if(int(s[i]) > 64 && int(s[i]) < 91 ) {
 	       licz++;
  	  }
 	   if (isspace(s[i])) {//(s[i] == ' ') {
 	   	if (licz >= m) {
 	   	m = licz;
  	 	 }
    		licz = 0;
		}
	}
	cout<<max(m,licz);
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int ans=0;
    string s;
    while(true) {
        cin>>s;
        if(cin.eof()) break;
        int tmp=0;
        FORE(x,s) {
            if('A'<=x && x<='Z') tmp++;
        }
        chmax(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}

#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>

using namespace std;

#define FOU(i,x,y) for(int i=x;i<=y;i++)
#define FOD(i,x,y) for(int i=x;i>=y;i--)
#define MEM(a,val) memset(a,val,sizeof(a))
#define PI acos(-1.0)

const double EXP = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll MINF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9+7;
const int N = 1e6+5;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    std::ios::sync_with_stdio(false);
    int n;
    scanf("%d",&n);
    getchar();
    char a[205];
    for(int i=1;i<=n;i++)
        scanf("%c",&a[i]);
    a[0]=' ';
    int ans=0;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i-1]==' '&&a[i]!=' ')
        {
            ans=max(ans,cnt);
            cnt=0;
        }
        if(a[i]>='A'&&a[i]<='Z')
            cnt++;
    }
    ans=max(ans,cnt);
    cout<<ans<<endl;
    return 0;
}
/*2018-02-01 22:18:20.475*/

#include<cstdio>
#include<cctype>
int main()
{
    int m=0;
    char s[205];
    scanf("%*d");
    while(~scanf("%s",s))
    {
        int tmp=0;
        for(int i=0;s[i];i++)
        {
            if(isupper(s[i])) tmp++;
        }
        if(tmp>m) m=tmp;
    }
    printf("%d\n",m);
    return 0;
}/*2017-12-30 03:48:44.215*/

#include <bits/stdc++.h>

using namespace std;

char s[101010];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n; cin>>n;
	gets(s);
	gets(s);
	int ans = 0, tmp = 0;
	for(int i=0; i<=n; i++) {
		if(s[i] >= 'A' && s[i] <= 'Z') tmp++;
		else if(s[i] < 'a') ans = max(ans, tmp), tmp=0;
	}
	cout<<ans;

    return 0;
}

#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
using DO=double;
using INT=long long;
using pii=pair<int,int>;
using pi3=pair<pii,int>;
template<typename T,typename U> inline void smin(T &a,const U &b) {if(a>b) a=b;}
template<typename T,typename U> inline void smax(T &a,const U &b) {if(a<b) a=b;}
int power(int a,int b,int mod,int ans=1){
	for(;b;b>>=1,a=1LL*a*a%mod) if(b&1) ans=1LL*ans*a%mod;
	return ans;
}
char s[100100];

int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n;
	scanf("%d",&n);
	int mx=0;
	while(scanf("%s",s)==1){
		int l=strlen(s);
		int N=0;
		for(int i=0;i<l;i++) if(s[i]>='A' and s[i]<='Z') N++;
		mx=max(mx,N);
	}
	cout<<mx<<endl;
	return 0;
}

#include<bits/stdc++.h>

using namespace std;
char s[202];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif

	int ans = 0;
	while(~scanf("%s", s)) {
		int num = 0;
		for(int i = 0; s[i]; i++) {
			if(isupper(s[i])) num++;
		}
		ans = max(ans, num);
	}
	cout<<ans;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin>>n;
    cin.ignore();
    string s1;
    getline(cin , s1 );
    int counter=0,max=0;
    for(int i=0 ; i<n ; ++i){
        if(s1[i]>='A' && s1[i]<='Z')++counter;
        else if(s1[i]==' '){
            if(counter>max)
                max=counter;
            counter=0;
        }
    }
    if(counter>max)max=counter;
    cout<<max<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;

int n;
string s;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    clock_t ck;
    ck = clock();
    cin >> n;
    cin.ignore();
    getline(cin,s);
    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == ' ')
            cnt = 0;
        if ('A' <= s[i] && s[i] <= 'Z')
            cnt++;
        ans = max(ans,cnt);
    }
    cout << ans << '\n';
    ck = clock()-ck;
    cerr << "It took " << 1.0*ck/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

#include <iostream>
#include <string>
using namespace std;

int main() {
	int n;
	cin >> n;
	string a;
	cin.ignore();
	getline(cin, a);
	int answer = 0;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] >= 'A' && a[i] <= 'Z')
			ans++;
		if (a[i] == ' ')
		{
			if (ans > answer)
			{
				answer = ans;
			}
			ans = 0;
		}
	}
	if (answer == 0 || answer < ans)
		answer = ans;
	cout << answer;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int term,c=0,m=0;
    cin>>term;
    string line;
    getline(cin,line);
    getline(cin,line);
    for(int i=0;i<=term;i++)
    {
        if(line[i]==' ' || line[i]=='\0')
        {
            m=max(m,c);
            c=0;
        }
        else if(line[i]<97)
            c++;
    }
    cout<<m<<endl;
    return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	int k, max = 0;
	cin >> k;
	while (cin >> s)
	{
		k = 0;
		for (int i = 0; i < s.size(); i++)
			if (s[i] >= 'A'&&s[i] <= 'Z')
				k++;
		if (k > max)
			max = k;
	}
	cout << max << endl;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s, k;
    int j=0, n, l=0, h=0;
    cin>>n;
    getline(cin, k);
    getline(cin, s);
    for(int i=0; i<s.length(); i++)
    {
        if(s[i]==' ')
        {
            h=max(h, l);
            j=0;
        }
        if(s[i]>='A' && s[i]<='Z')
        {
            j++;
            l=j;
        }

    }
    h=max(h, l);

    cout<<h;
}

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <utility>
#include <map>
#include <queue>
#include <iterator>
using namespace std;

int main() {
	int n; cin >> n;
	char trash; cin >> trash;
	int maxVol = 0;
	int vol = 0;
	string s;
	getline(cin, s);
	s = trash + s;
	for (int i = 0; i < n; i++) {
		if (s[i] == ' ') {
			vol = 0;
		}
		else if (s[i] <= 'Z' && s[i] >= 'A') {
			vol++;
			maxVol = max(maxVol, vol);
		}
	}
	cout << maxVol;
}

#include <iostream>

using namespace std;

int main()
{
    string str; int HV=0, CV=0;
    getline(cin, str);
    getline(cin, str);
    for(int i=0;i<str.length();i++){
        if(str[i]< 91 && str[i]> 64){CV++;}
        if(CV>HV){HV=CV;}
        if(str[i]==32){CV=0;}
    }
    cout << HV;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;
	int max = 0;
	int count = 0;
	char c;
	cin >> noskipws >> c;

	for (int i = 0; i < n; i++)
	{
		cin >> noskipws >> c;
		if (c >= 65 && c <= 90)
			count++;
		else if (c == 32)
			count = 0;

		if (count > max)
			max = count;
	}

	cout << max;
}

#include <iostream>
#include <vector>
#include <string>

using namespace std;

vector<string> split(string s) {
	vector<string> myVec;
	int past = 0;
	int temp = s.find(" ", past);
	while (temp != -1) {
		myVec.push_back(s.substr(past, temp-past));
		past = temp+1;
		temp = s.find(" ", past);
	}
	myVec.push_back(s.substr(past));
	return myVec;
}

int main() {

	string temp;
	getline(cin, temp);
	int num = stoi(temp);
	string sentence;
	getline(cin, sentence);
	if (sentence.length() > num)
		sentence = sentence.substr(0, num);
	vector<string> a = split(sentence);
	vector<string>::iterator it = a.begin();
	int score = 0;
	for (; it < a.end(); it++) {
		int localscore = 0;
		string placeholder = *it;
		for (int i = 0; i < placeholder.length(); i++)
		{
			if (placeholder[i] >= 'A' && placeholder[i] <= 'Z')
				localscore++;
		}
		if (localscore > score)
			score = localscore;
	}
	cout << score;
	return 0;
}

#include<stdio.h>

int main()
{
    int n;
    char words[210];
    scanf("%d", &n);
    getchar();
    fgets(words, n + 1, stdin);
    int res = 0;
    int count = 0;
    for(int i = 0; i < n; ++i)
    {
        if (words[i] == ' ')
        {
            if (count > res)
                res = count;
            count = 0;
        }
        else
        {
            if ('A' <= words[i] && words[i] <= 'Z')
            {
                count += 1;
            }
        }
    }

    if (count > res)
        res = count;
    printf("%d\n", res);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int i,c=0,ans=0;
    string s;
    cin.ignore();
    getline(cin,s);
    for(i=0;i<n;i++)
    {
        if(s[i]>='A'&&s[i]<='Z')
            c++;
        if(s[i]==' ')
        {
            ans=max(ans,c);
            c=0;
        }
       // cout<<"Hello";
    }
    ans=max(ans,c);
    cout<<ans<<endl;
}

/* Text Voolume
 * 837a
 * cf
 */

#include<bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int len, ma = -1e10;
    string t;
    cin >> len;
    while(cin >> t) {
//        cout << t  << " is cureent \n";
        int count = 0;
        for(int i = 0; i < t.length(); ++i) {
            if(t[i] >= 'A' and t[i] <= 'Z') {
                count++;
            }
            ma = max(count, ma);
        }
    }

    cout << ma << "\n";
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <queue>
using namespace std;
typedef long long ll;
int main(){
	char a[233];
	int len;
	while(scanf("%d",&len)!=EOF)
	{
		getchar();
		gets(a);
		int i,j;
		int ans=0;
		i=0;
		while(i<len)
		{
			int js=0;
			while(a[i]!=' '&&i<len)
			{
				if(a[i]>='A'&&a[i]<='Z')
				js++;
				i++;
			}
			if(js>=ans)ans=js;
			i++;
		}
		printf("%d\n",ans);
	}
	return 0;
} /*2018-07-28 21:30:10.859*/

/* Text Voolume
 * 837a
 * cf
 */

#include<bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int len, ma = -1e10;
    string t;
    cin >> len;
    while(cin >> t) {
//        cout << t  << " is cureent \n";
        int count = 0;
        for(auto i : t) {
            if(i >= 'A' and i <= 'Z') {
                count++;
            }
            ma = max(count, ma);
        }
    }

    cout << ma << "\n";
    return 0;
}

#include<stdio.h>
#include<string.h>
char str[233];
int main()
{
    int n;
    scanf("%d",&n);
    int len=0;
    int ans=0;
    while(len<n)
    {
        scanf("%s",str);
        len+=strlen(str)+1;
        int sum=0;
        for(int i=0;str[i];i++)
            if(str[i]>='A'&&str[i]<='Z')
            sum++;
        if(sum>ans)ans=sum;
    }
    printf("%d\n",ans);
}
/*2017-11-26 16:29:28.506*/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int c=0,n=0,v;
    string s;

    cin>>v;
  while(cin>>s){
            for(int i=0;i<s.length();i++)
            {
                     if(s[i]>=65&&s[i]<=90) c++;

            }
            n=max(n,c);
            c=0;
    }

    cout<<n<<endl;

    return 0;
}

#include<stdio.h>
#include<string.h>
char str[222];
int main()
{
    int n;
    scanf("%d",&n);
    getchar();
    gets(str);
    int ans=0,sum=0;
    for(int i=0;i<n;i++)
    {
        if(str[i]>='A'&&str[i]<='Z')
            sum++;
        if(str[i]==' ')
        {
            if(sum>ans)ans=sum;
            sum=0;
        }
    }
    if(sum>ans)ans=sum;
    printf("%d\n",ans);

    return 0;
}
/*2017-11-26 17:41:17.436*/

/*____________________________________

           CODE IS LIFE <@_@>
____________________________________*/

#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <set>
#include<stack>
#include<array>
#include<string>

///...define...///

#define ll  long long
#define ull unsigned long long

///...Input...///
#define S1(a)  scanf("%d",&a)
#define SL1(a)  scanf("%lld",&a)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
#define S2(a,b)   scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL3(a,b,c)  scanf("%lld%lld%lld",&a,&b,&c)

///...Declared Input...///
#define DI(X)          int X;      scanf("%d", &X)
#define DII(X, Y)      int X,Y;    scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z)  int X,Y,Z;  scanf("%d%d%d", &X, &Y, &Z)
#define DLI(X)         ll X;       scanf("%lld", &X)
#define DLII(X, Y)     ll X,Y;     scanf("%lld%lld", &X, &Y)
#define DLIII(X, Y, Z) ll X,Y,Z;   scanf("%lld%lld%lld", &X, &Y, &Z)

///...Loop...///
#define fai(i,a)        for(ll i=0; i<a; i++)
#define faj(j,a)        for(ll j=0; j<a; j++)
#define fab(a, b)       for(ll i=a; i<=b; i++)
#define rfai(i, a)        for(ll i=a-1; i>=0; i--)
#define fabi(a,b,inc)   for(ll i=a; i<=b; i+=inc)
#define fabd(a,b,dec)   for(ll i=a; i>=b; i-=dec)

///...Minimum/Maximum...///
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))

///...PrintCase...///
#define PC(a)      printf("Case %d: ",a)
#define PCN(a)     printf("Case %d:\n",a)
#define PCH(a)     printf("Case #%d: ",a)

///...Pair...///
#define ff  first
#define ss  second
#define MP  make_pair
#define vec  vector< int >
#define vv vector< vi >
#define vll vector< ll >
#define pii pair< int , int >
#define pll pair< ll , ll >
#define vpi vector< pii >

///...Other Operations...///
#define pi         2.0*acos(0.0)
#define eps        1e-11
#define sqr(n)     n*n
#define all(a)     a.begin(),a.end()
#define nl         "\n"
#define check      P("here\n")
#define gch        getchar()
#define pb         push_back
#define pp         pop_back
#define sz()       size()
#define SUM(a,n)   accumulate(a,a+n,0)
#define READ(f)    freopen(f, "r", stdin)
#define WRITE(f)   freopen(f, "w", stdout)
#define Dpos(n)    fixed<<setprecision(n)
#define w(t)        cin>>t; while(t--)
#define count_bit(n)      __builtin_popcount(n)

///...define mathematics...///
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define MAX 1000

using namespace std;

///...Mathematics...///
template <typename T> T BigMod(T b,T p,T m){if(p==0)return 1;if(p%2==0){T s=BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T POW(T B,T P){    if(P==0)        return 1;    if(P&1)    return B*POW(B,P-1);    else      return sqr(POW(B,P/2));}
template <typename T> T gcd(T a,T b){    if(a<0)        return gcd(-a,b);    if(b<0)        return gcd(a,-b);    return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b){    if(a<0)        return lcm(-a,b);    if(b<0)        return lcm(a,-b);    return a*(b/gcd(a,b));}

///...String Operation...///
// int sumDigits(int n){ int sum = 0; while (n != 0) { sum += n % 10; n /= 1; }  return sum;   }

int b2d(long long n){    int decimalNumber = 0, i = 0, remainder;    while (n!=0)    {        remainder = n%10;     n /= 10;        decimalNumber += remainder*pow(2,i);  ++i; }    return decimalNumber;}
vector<ll> decToBinary(int n) {    vector<ll> binaryNum(12);   while (n > 0) {   binaryNum.pb( n % 2);  n = n / 2; }     reverse(all(binaryNum));   return binaryNum;}

int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
ll toLlint(string s) { ll sm; stringstream ss(s); ss>>sm; return sm; }
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false; }
template <class T> string NTS ( T Number ){stringstream ss;ss << Number;return ss.str();}
bool isprime(int w){if(w == 0) return false;if(w == 1) return false;int sqrtw = int(sqrt((double)w));for(int q = 2; q <= sqrtw; q++){if(w % q == 0) return false;}return true;}

#define   IOS   {ios_base::sync_with_stdio(0); cin.tie(0);}

///.............End Of Template..............////
// ll binarySearch(ll *arr,ll low,ll high,ll key){

// 	while(low<= high){
// 		ll mid= (low+high)/2;
// 		if(arr[mid]>key){
// 			high=mid-1;
// 		}
// 		else if (arr[mid]<key){
// 			low=mid+1;
// 		}
// 		else {
// 			return mid;
// 		}
// 	}
// 	return -1;
//}

int main()
{   IOS;
    ll n;
    cin>>n;

   string xx;
    ll cnt=0,mx=0;
    while(cin>>xx){
         cnt=0;
        for(ll i=0;i<xx.sz();i++){
        	if(xx[i]>='A' and xx[i]<='Z')cnt++;
        mx= max(mx,cnt);

        }
    }
    cout<<mx<<nl;
}

#include<stdio.h>
#include<string.h>
char x[205];
int main()
{
    int n;int a;int maxl;int b;int i;
    while(~scanf("%d",&n))
    {
        getchar();
        gets(x);
        b=0;maxl=0;
        a=strlen(x);
        for(i=0;i<n;i++)
        {
            if(x[i]>='A'&&x[i]<='Z')
                {b++;}
                if(x[i]==' '||i==n-1)
                {if(b>maxl)
                    {maxl=b;}
                    b=0;
                }
        }
        printf("%d\n",maxl);
    }
    return 0;
}
/*2017-11-26 15:46:35.904*/

#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n;
	cin>>n;
	string a;
	int volume=0,word_vol=0;

	while(cin>>a)
	{
		word_vol=0;
		for (int i=0;i<a.size();i++)
		{
			if (isupper(a[i]))
				word_vol++;
			if (word_vol>volume)
				volume=word_vol;
		}
	}

	cout<<volume;
}

#include<bits/stdc++.h>
using namespace std;
#define dd double
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ll long long
#define ull unsigned long long
#define ld long double
#define mx 100005
#define mod 1000000007
#define fr first
#define cti(a) (a-48)
#define itc(a) char(a+48)
#define se second
#define End cout<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define memo(Array,val) memset(Array, val, sizeof Array)
#define PI acos(-1)
bool check(ll n, ll pos){ return (n&(1<<pos)); }
bool Set(ll n, ll pos) {  return (n | (1<<pos)); }
ld LOG(ld b, ld e){ return log(b)/log(e); }

int func(string s)
{
    int N=0;
    for(int i=0; s[i]; i++) N+=(s[i]>='A' && s[i]<='Z');
    return N;
}

void solve(int kk)
{
    int n,mm=-1;
    cin >> n;
    string s1;
    while(cin >> s1) mm = max(mm,func(s1));
    cout << mm << "\n";
}

int main()
{
   fast;
   int t=1,kk=0;
   //cin >> t;
   while(++kk<=t) solve(kk);

   return 0;
}

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int ans=0,cnt=0;
    for(int i=1;i<=n;i++)
    {
        char ch=getchar();
        while((ch<'a'||ch>'z')&&(ch<'A'||ch>'Z')&&ch!=' ') ch=getchar();
        if(ch==' ') {ans=max(ans,cnt);cnt=0;}
        else if(ch>='A'&&ch<='Z') cnt++;
    }
    ans=max(ans,cnt);
    cout<<ans<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

/*link https://codeforces.com/contest/837/problem/A */
/*input
7
NonZERO
*/
/*output
5
*/
/*input
24
this is zero answer text
*/
/*output
0
*/
/*input
24
Harbour Space University
*/
/*output
1
*/

int main () {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int ma = 0;
	int n;
	cin >> n;
	cin.ignore(10,'\n');
	cin >> noskipws;
	//test
	int z = 0;

	for (int i = 0; i < n; i++) {
		char x;
		cin >> x;

		if (x == ' ') {
			z = 0;
		}
		else if (isupper(x))
			z++;

		ma = max(ma, z);
	}

	cout << ma;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int mx=0,count=0,n,l,i;
    string s;

    cin>>n;
    getline(cin , s ) ;
    getline(cin , s) ;

        l=s.size();
        for(i=0;i<l;i++)
        {
            if(s[i] == ' ' )
                count = 0 ;
            else
            if(s[i]>='A' && s[i]<='Z')
            {
                count++;
            }
            mx=max(mx,count);
         }
                    cout<<mx<<endl;
                    return 0;

}

# include <iostream>
# include <cstdio>
# include <cstring>
# include <string>
using namespace std;
char s[205];
int sum;
void cha(int start,int got)
{
	int p=0;
	for(start;start<=got;++start)
	{
		if(s[start]>='A'&& s[start]<='Z') ++p;
	}
	if(p>sum) sum = p;
}
int main ()
{
	int n,i,t;
    scanf("%d",&n);
    getchar();
    for(i = 0;i<n;++i)
    {
    	scanf("%c",&s[i]);
    }
	sum = 0;
    for(i = 0;i<n;++i)
    {
    	if(s[i]!=' ')
    	{
	    	for(t = i;t<n && s[t]!=' ';++t){}
	    	--t;
	    	cha(i,t);
	    	i = t;
	    }
    }
	cout << sum << endl;
	return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define pb push_back
#define eb emplace_back
#define sll set<ll>
#define ins insert
#define rep(i,n) for(int i=0;i<n;i++)
#define vpp vector<pair<int,int>>
#define mp make_pair
#define ft first
#define sc second
#define gp " ";
#define MAX 9999999
#define MOD 1000000007
#define mnn(v2) *min_element(v2.begin(),v2.end());
#define mxx(v2) *max_element(v2.begin(),v2.end());
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll t=1;
  //cin>>t;
  while(t--){
          ll m,n,i,j,k,c=0,mx=0;
          cin>>n;
          string s;
          while(cin>>s)
          {
                    c=0;
                    rep(i,s.size())
                    {
                              if(s[i]>='A' && s[i]<='Z')
                                        c++;
                    }
                    mx=max(c,mx);
          }
          cout<<mx;

  }
}

#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    char s[202];
    int n;
    cin >> n;
    cin.ignore();
    cin.getline(s , 201); // Ensure.
    int sum = 0 , mx = 0;
    for(int i = 0 ; i < n ; i++) {
        if(s[i] == ' ') {
            mx = max(mx , sum);
            sum = 0;
        } else if(s[i] <= 'Z') {
            ++sum;
        }
    }
    cout << max(mx , sum);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define PB pop_back
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;

void solve(){
    int n, ans = 0, cnt = 0;
    string s;
    cin >> s;
    while(cin >> s) {
        int cnt = 0;
        for (char c : s) {
            if ('A' <= c && c <= 'Z')
                cnt++;
        }
        ans = max(ans, cnt);
    }
    cout<<ans;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) ((int) x.size())
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;

int main() {sws;

    int n;
    string s;
    cin >> n;
    getline(cin, s);
    getline(cin, s);

    int cont = 0;
    int maior = 0;
    for ( auto l : s ) {
        // cout << l << endl;
        if ( l >= 'a' and l <= 'z' ) {
            // cout << "fudeu\n";
            continue;
        }
        else if ( l >= 'A' and l <= 'Z' ) {
            // cout << "alo?\n";
            maior = max(maior, ++cont);
        }
        else cont = 0;
    }

    cout << maior << endl;

    return 0;
}

#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int maxnum,tempnum;
    maxnum=0;
    tempnum=0;
    int flag=0;
    char a;
    while(n>=0)
    {
        cin>> noskipws >> a;
        if(a==32)
        {
            if(tempnum>maxnum)
            {
            maxnum=tempnum;
            }
            tempnum=0;
            flag=1;
        }
        else if(a>='A'&&a<='Z')
        tempnum++;
        n--;
    }
    if(tempnum>maxnum)
            {
            maxnum=tempnum;
            }
    if(flag==0)
    {
        cout<<tempnum;
    }
    else
        cout<<maxnum;
}

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n;
char a[205];
int ans,cnt,temp;
int main()
{
	cin>>n;
	getchar();
	gets(a);
	for(int i=0;i<n;i++)
	{
		if(a[i]==' ')break;
		if(i==n-1)
		{
			for(int i=0;i<n;i++)
				if(a[i]>='A'&&a[i]<='Z')cnt++;
			cout<<cnt<<endl;
			return 0;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]==' ')
		{
			for(int j=temp;j<i;j++)
			{
				if(a[j]>='A'&&a[j]<='Z')cnt++;
			}
			if(ans<cnt)ans=cnt;
			cnt=0;
			temp=i+1;
		}
		if(i==n-1)
		{
			for(int j=temp;j<=i;j++)
			{
				if(a[j]>='A'&&a[j]<='Z')cnt++;
			}
			if(ans<cnt)ans=cnt;
		}
	}
	cout<<ans<<endl;
	return 0;
}

#pragma comment(linker, "/STACK:256000000")
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include <set>
#include <queue>
#include <map>
#include <vector>

using namespace std;

#define mp make_pair
#define con continue
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector < vector < int> > vvi;
typedef vector < vector < pair < int, int > > > vvii;

int main()
{
//	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	char c;
	scanf("%c", &c);

	ll ans = -1;
	ll curAns = 0;
	for (int i = 0; i < n; ++i)
	{
		char c;
		scanf("%c", &c);
		if (c >= 'A' && c <= 'Z')
			curAns++;
		if (c == ' ')
		{
			if (ans < curAns)
				ans = curAns;
			curAns = 0;
		}
	}
	if (ans < curAns)
		ans = curAns;
	cout << ans;
	return 0;
}

#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
    int n;
    cin>>n;
    int count=0,max=0;
    string temp;
    cin.ignore();
    getline(cin,temp);
    for(int i=0;i<n;i++){
        if(temp[i]==' '){
            max=(max>count)?max:count;
            count=0;
        }
        else if(temp[i]>='A' && temp[i]<='Z'){
            count++;
        }
    }
    max=(max>count)?max:count;
    cout<<max;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, jav = 0;
    string s;
    cin >> n;
    while (n > 0) {
        int x = 0;
        cin >> s;
        int a = s.size();
        for (int i = 0; i < a; i ++)
            if (s[i] >= 'A' && s[i] <= 'Z')
                x ++;
        jav = max(jav, x);
        n --;
        n -= s.size();
    }
    cout << jav << endl;
    return 0;
}

#include <iostream>
#include <string>

using namespace std;

int main()
{
          int n = 0, a = 0, b = 0;
          string s = "";
          cin >> n;
          while (cin >> s)
          {
                    n = s.size();
                    for (int i = 0; i < n; i++)
                    {
                              if(int(s[i]) < 97)
                              {
                                        a++;
                              }
                    }
                    if (a > b)
                    {
                              b = a;
                    }
                    a = 0;
          }
          cout << b;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin>>n;
    getchar();

    char ss[222];
    int ans=0,anss=0;
    gets(ss);

    for(int i=0;i<=n;i++)
    {
        if(ss[i]<='Z' && ss[i]>='A' &&ss[i]!=' ')
            ans++;

        if(ss[i]==' ')
        {
            anss=max(anss,ans);
            ans=0;
        }
    }

    anss=max(anss,ans);

    cout<<anss<<endl;

   return 0;

}

#include<bits/stdc++.h>
using namespace std;
string s;
int a,b,to;
int ans=1e-9;
int main()
{
    cin>>a;
    while(b<a)
    {
        to=0;
        cin>>s;
        b+=s.size()+1;
        for(int i=0;i<s.size();i++)
          if(s[i]>='A'&&s[i]<='Z')
            to++;
        ans=max(ans,to);
    }
    cout<<ans;
    return 0;
}

#include<iostream>
#include<cstring>
using namespace std;

string s;
int a,b,tot,i,ans=-2147483633;

int main()
{
	tot=0;
	cin>>a;
	while(b<a)
	{
		tot=0;
		cin>>s;
		b+=s.size()+1;
		for(i=0; i<s.size(); i++)
			if(s[i]>='A'&&s[i]<='Z')
				tot++;
		ans=max(ans,tot);
	}
	cout<<ans;
	return 0;
}

#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main()
{
    int n, s = 0, Max = 0;
    string ss;
    scanf("%d", &n);
    //cin >> ss;
    int k = 0;
    do {
        cin >> ss;
        k += ss.size() + 1;
    for (int i = 0; i < ss.size(); i++)
    {
        char a = ss[i];
        char b = toupper(a);

        if (b == a)
        {
            s ++;
        }
    }

        if (s > Max)
        {
            Max = s;
        }
        s = 0;
    }
    while (k < n);

    printf("%d", Max);

    return 0;
}

#pragma comment(linker, "/STACK:168777216")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
using namespace std;

int const MAX_N = 256 * 1024;
char st[MAX_N];
int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	gets(st);
	gets(st);
	int n = (int) strlen(st);
	st[n] = ' ';
	n++;

	string word = "";
	int mx = 0;
	for (int i=0; st[i]; i++)
		if ((st[i] >= 'a' && st[i] <= 'z') || (st[i] >= 'A' && st[i] <= 'Z')) word += st[i];
		else {
			if (word.length() > 0) {
				int cnt = 0;
				for (int j=0; j<(int) word.length(); j++)
					if (word[j] >= 'A' && word[j] <= 'Z')
						cnt++;
				mx = max(mx,cnt);
			}
			word = "";
		}
	cout<<mx;
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

main()
{

    int i,n,c=0,d=0;

    cin>>n;

    scanf("\n");
    string a;
    getline(cin,a);
    for(i=0;i<n;i++){
        if(a[i]>='A'&&a[i]<='Z') d++;
        else if(a[i]==' '){c=max(c,d); d=0;}
    }
    c=max(c,d);
    cout<<c <<endl;
}

#include<bits/stdc++.h>
using namespace std;string s;int a,b,tot,i,ans=-2147483633;int main(){tot=0;cin>>a;while(b<a){tot=0;cin>>s;b+=s.size()+1;for(i=0;i<s.size();i++)if(s[i]>='A'&&s[i]<='Z')tot++;ans=max(ans,tot);}cout<<ans;}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,maxx=0,cnt=0;
    cin>>n;
    cin.ignore();
    string s;
    getline(cin,s);
    for(int i=0;i<n;i++)
    {
        if(s[i]>='A' && s[i]<='Z')
        {
            cnt++;
        }
        else if(s[i]==' ')
        {
            if(maxx<=cnt)
            {
                maxx=cnt;
            }
            cnt=0;
        }
    }
    if(maxx<=cnt)
    {
        maxx=cnt;
    }
        cout<<maxx;
}

#include <iostream>

using namespace std;

int main()
{
    string s,s1;
    int k , m ,n,sum;
    int b;
    cin >> n;
    bool f;
    f=false;
    k=0;
    sum=0;
    m=0;
    while (f==false && sum<n)
    {
        cin >> s;
        for (int i=0;i<s.length();i++)
        {
            int b = s[i];
            if (b>=65 && b<=90)
                k++;
        }
        if (k>m) m=k;
        k=0;
        if (s.length()+sum==n)
            f=true;
        else
          {
            sum+=s.length();
            n--;
          }
    }
    cout << m;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
string c;
int d = 0,n,ans = 0;
int main()
{
    cin>>n;
    while (cin>>c)
    {
        d = 0;
        for (int i = 0; i < c.size(); i++)
            if (c[i] >= 'A' && c[i] <= 'Z') d++;
        ans = max(ans,d);
    }
    cout<<ans;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#define re register int
using namespace std;

int l,ans;
string str;

int main()
{
	ios::sync_with_stdio(false);

	std::cin>>l;

	re i=0;
	while(i<l)
	{
		re len,cnt=0;
		std::cin>>str;
		len=str.length();
		i+=len+1;
		for(re j=0;j<len;j++)
			if(str[j]>='A'&&str[j]<='Z')
				cnt++;
		ans=std::max(ans,cnt);
	}

	std::cout<<ans;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int n;
char str[220];
int ans, tmp;
int main()
{
    while(~scanf("%d",&n))
    {
        getchar();
        gets(str);
        ans = tmp = 0;
        for(int i=0;i<n;i++)
        {
            if(str[i]==' ')
            {
                ans = max(ans,tmp);
                tmp=0;
            }
            else if(str[i]>='A'&&str[i]<='Z') tmp++;
        }
        ans = max(ans,tmp);

        cout << ans <<endl;
    }
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
char a[1000];
int main()
{
	//freopen("standard.in","r",stdin);
	//freopen("standard.out","w",stdout);
	int n;
	cin>>n;
	cin.get();
	string s;
	getline(cin,s);
	//cout<<s[0]<<endl;
	int sum=0,maxx=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]>='A'&&s[i]<='Z')
			sum++;
		if(s[i]==' ')
		{
			maxx=max(sum,maxx);
			sum=0;
		}
	}
	maxx=max(sum,maxx);
	cout<<maxx<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

char str[205];

int main () {
	int n, mx = 0;
	scanf ("%d", &n);
	while (scanf ("%s", str) != EOF) {
		int ans = 0;
		int len = strlen (str);
		for (int i = 0; i < len; ++i)
			ans += (str[i] >= 'A' && str[i] <= 'Z') ? 1 : 0;
		mx = max (mx, ans);
	}
	cout << mx << endl;
	return 0;
}

#include <iostream>
#include <cstring>
using namespace std;
int main(){
    string s;
    int a,amt,max,x;
    amt=0;
    max=0;
    cin>>a;
    while (cin>>s){
    	for (x=0;x<s.length();x++){
    		if (isupper(s[x])){
    			amt++;
    		}
    	}
    	if (amt>max){
    		max=amt;
    	}
    	amt=0;
    }
    cout<<max<<endl;
    return 0;
}

#include<cstdio>
int main()
{
   int n,s=0,z=0;
   char t;
   scanf("%d",&n);
   for(int i=0;i<n+1;i++)
   {
       scanf("%c",&t);
       if(t<92&&t>64)
       {
           s++;
       }
       if(t==' ')
       {
           if(s>z)
                z=s;
            s=0;
       }

   }

   if(s>z)
    printf("%d",s);
   else
    printf("%d",z);
}

#include<bits/stdc++.h>
#define ll long long
#define fr(i,x) for( int i=0;i<(x);i++)
#define endl '\n'
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main()
{
    int t,c=0,ans=0,upper=0;
    cin>>t;
   string s;
   cin.ignore();
   getline(cin, s);

   for (int i = 0; i <t; i++)
    {
      if(s[i]>='A' && s[i]<='Z')
       {
          upper++;
          ans=max(upper,ans);
       }
       else if(s[i]==' ')
		{
        upper=0; }

   }
     cout<<ans;
    return 0;

}

#include <iostream>
#include <string>
#include <ctype.h>

using namespace std;

int main()
{
    int n, k = 0;
    cin >> n;
    string a;
    cin.ignore();
    getline(cin, a);
    int mx = 0;
    for (int i = 0; i < n; i++){
        if (isupper(a[i])){
            k++;
        } if (a[i] == ' '){
            if (k > mx){
                mx = k;
            }
            k = 0;
        }
    }
    if (k > mx){
        mx = k;
    }
    cout << mx;
    return 0;
}

#include<cstdio>
#include<iostream>

using namespace std;

int main()
{
	int kk;
	cin>>kk;
	char st[kk]={0},xx[100];

	int sum=0,max=0;
	gets(xx);
	gets(st);

	for(int i=0;i<kk;i++)
	{

		for(char j='A';j<='Z';j++)
		{
			if(st[i]==j) {sum++;}
		}

		if((st[i]==' ')||(i==(kk-1)))
		{
			if(max<sum) {max=sum;}
			sum=0;
		}
	}

	cout<<max;
	return 0;
}

#include<bits/stdc++.h>
#define Nazar ios_base::sync_with_stdio(0);
#define ll long long
#define r_0 return 0;
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );
using namespace std;
string s,sum,m;
ll mx ;
ll int  a,b = 1,c = 1,d,e,f,cnt,snt,ans,n,q;
int arr[101];
vector<int>v;
char w;
int main ()
{
   //fin( "input.txt" );
   // fout( "output.txt" )
   Nazar
   /* cin >> a >> s >> m;
    if (a >= 1 && a <= 29 and m == "month")
    {
        cout << 12;
    }
    else if (a >=1 && a <=4 and m== "week")
    {
        cout << 52;
    }
    else
    {
        cout << 53;
    }*/
    cin >> a;
    getline( cin ,s);
  getline (cin , s);
  for ( int i = 0; i <=s.size(); i ++)
  {
      if (s[i] >= 65 && s[i] <= 90 )
       cnt++;
       mx = max ( cnt , mx );
        if ( s [ i ] == ' ')
        {
            cnt = 0 ;
        }
  }
  cout << mx;

}

#include <bits/stdc++.h>

using namespace std;
int main()
{
   int n,c=0,d=0,a;
   cin>>n;
 cin.ignore();
   string s;
   getline(cin,s);
   for(int i=0;i<n;i++)
   {
       if(s.at(i)==' ')
       {
           d++;
       }
   }
   vector<int>v;
  for(int i=0;i<n;i++)
  {
      if(s.at(i)>=65&&s.at(i)<=90)
      {
          c++;
      }
     a=c;
       if(s.at(i)==' ')
       {
           v.push_back(c);
            c=0;
        }

  }
  if(d==0)
  {
      cout<<c;
  }
  else
  {
    sort(v.begin(),v.end());

    if(a>v[v.size()-1])
    {
        cout<<a;
    }
    else
    {
        cout<<v[v.size()-1];
    }

  }

    return 0;
}

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int n, ans = 0, ss = 0;
	cin >> n;
	for (int i = 0; i <= n; i++) {
		char s;
		s = getchar();
		if (s >= 'A' && s <= 'Z') {
			ans++;
		}
		if (s == ' ') {
			ans = max(ans, ss);
			ss = ans;
			ans = 0;
		}
	}
	cout << max(ans, ss) << endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    IOS;
    long long a,b,c,d,e,f,g,n,t,flag=0,co=0,co1=0,arr1[10001],arr[200001],sum=0,sum1=0,ma=0,mi=10000000000;
    int x[]={1,0,-1,0};
    int y[]={0,1,0,-1};
    string str,str1,str2;
    //char str[1000];
    set<long long>s;
    set<long long>::iterator it;
    vector<long long>v;
    vector<long long >v1;
    vector<pair<int,int> >v2;
    cin>>n;
    while(cin>>str)
    {

    co=0;
    for(int i=0; i<str.size(); i++)
    {
        if(str[i]>='A' && str[i]<='Z')
            co++;
        ma=max(ma,co);
    }
    }
    cout<<ma<<endl;
    return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ans=0,maxx=0;
	char st[200];
	cin>>n;
	gets(st);
    gets(st);
	for(int i=0;i<n;i++)
		if(st[i]>='A'&&st[i]<='Z')ans++;
			else if(st[i]==' '){maxx=max(maxx,ans);ans=0;}
	cout<<max(maxx,ans)<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

main(){

	int n;
	cin>>n;
	int count=0;
	int count1=0;
	string h;

	while(cin>>h){
	    count=0;
	    for(int i=0;i<h.size();i++)
	        if(isupper(h[i])) count++;
	   count1=max(count,count1);
	}

	//cout<<count;

	cout<<count1;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
		cin>>n;
	string s;
	cin.ignore();
	getline(cin,s);
	int ans=0,mx=0;
	s[s.size()]=' ';
	for(int i=0;i<=s.size();++i)
	{
		if(s[i]-'0'< 49 && s[i] != ' ') ans++;
		if(s[i] == ' ' )
		{
			if(ans >= mx) mx = ans;
			ans=0;

		}
	}
	cout<<mx<<endl;
}

#include <bits/stdc++.h>

using namespace std;

int N, nr, MAX;
char s[204];
int main()
{
    cin >> N;
    cin.getline(s, 201);
    cin.getline(s, 201);
    for(int c = 0; c < N; c++) {
        if(s[c] == ' ')
            MAX = max(MAX, nr), nr = 0;
        else if(toupper(s[c]) == s[c] && isalpha(s[c]))
            nr++;
    }
    MAX = max(MAX, nr);
    cout << MAX << "\n";
    return 0;
}

/*input
199
o A r v H e J q k J k v w Q F p O R y R Z o a K R L Z E H t X y X N y y p b x B m r R S q i A x V S u i c L y M n N X c C W Z m S j e w C w T r I S X T D F l w o k f t X u n W w p Z r A k I Y E h s g
*/
#include <bits/stdc++.h>
using namespace std;

/*typedef vector<int> vi;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;*/

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())

#define      rep(i, n)         for(int i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(int i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(int i = a; i >= (n); --i)

int volume(string s){
    int t=0;
    rep(i,s.length())
        if(s[i]>='A' && s[i]<='Z') ++t;
    return t;

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    int i=0,ans=0;
    while(i<n){
        cin>>s;
        i+=s.length()+1;
        ans=max(ans,volume(s));
    }
    cout<<ans;

    return 0;
}

#include<iostream>
#include<stdio.h>
#include<string>
#include<cstring>
using namespace std;

int main()
{
	int n;
	cin >> n;
	string a;
	int ans = 0;
	while (cin >> a) {
		int t = 0;
		for (int i = 0; i < a.length(); i++) {
			if (a[i] >= 'A'&&a[i] <= 'Z') {
				t++;
			}
		}
		if (t > ans)ans = t;
	}
	cout << ans << endl;
	return 0;
}

#include<iostream>
using namespace std;
int main(){

	int n,count=0,a=0,f=1;
	cin>>n;
	string s;
	getline(cin,s);
	getline(cin,s);
	for(int i=0;i<n;i++){
		if(s[i]>=65&&s[i]<=90){
			count++;

			//cout<<count<<"ami";
			}
			if(count>=a){
			 a=count;
			//cout<<"azaz"<<count;

			 }
		if(s[i]==' ') {
			 f=0;
			count=0;

		}
		//cout<<"a"<<i<<s[i];

	}
	if(f==1) cout<<count<<endl;
	else cout<<a<<endl;
}

#include<iostream>
using namespace std;
int main()
{
    int n,c=0,mx=0;
    string a;
    cin>>n;
    getline(cin,a);
    getline(cin,a);
    for(int i=0;i<n;i++)
    {
        if(a[i]==' ')
            c=0;
        if(a[i]>='A'&&a[i]<='Z')
            c++;
        if(c>mx)
            mx=c;
    }
    cout<<mx<<endl;
    return 0;
}

#include<iostream>

using namespace std;

#define MAXSIZE 202

int main(){
	int n, ans=100000, current=0, word=0;
	char arg[MAXSIZE];
	cin>>n>>arg;
	for (int i = 0; i < n; ++i)
	{
		if(arg[i]!=char(' ')){
			if (arg[i]>='A' && arg[i]<='Z')
			{
				current++;
				word=max(word, current);
				//cout<<word<<endl;
			}
		}else{
			//cout<<word<<endl;
			current=0;
			word=0;
			ans=min(ans,word);
		}

	}
	ans=min(ans,word);
	cout<<ans<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,sum=0;
char s[100010];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s[i];
		if(s[i]<=90&&s[i]>=65) sum++;
	}
	cout<<sum;
}

#include<bits/stdc++.h>
using namespace std;
int n,cnt,ans;
char s[520233];
int main(){
    scanf("%d",&n);
    scanf("%s",s+1);
    s[++n]=' ';
    ans=cnt=0;
    for (int i=1;i<=n;i++){
        if (s[i]==' '){
            ans=max(ans,cnt);
            cnt=0;
        }else{
            if (s[i]>='A'&&s[i]<='Z'){
                cnt++;
            }
        }
    }
    printf("%d",ans);
}

# include <iostream>
# include <cstdio>
# include <cstring>
# include <string>
using namespace std;
char s[205];
int sum;
void cha(int start,int got)
{
	int p;
	if(start==got) p = 0;
	else
	{
		p = 0;
		for(start;start<=got;++start)
		{
			if(s[start]>='A'&& s[start]<='Z') ++p;
		}
	}
	if(p>sum)
	{
		sum = p;
	}
}
int main ()
{
	int n,i,t;
	cin >> n >> s;
	n = strlen(s);
	sum = 0;
	for(i = 0;i<n;++i)
	{
		if(s[i]==' ') continue;
		for(t = i;s[t+1]!=' '&& t<n;++t){}
		cha(i,t);
		i = t;
	}
	cout << sum << endl;
	return 0;
}

#include<iostream>
using namespace std;
int main(){

	int n,count=0,a=0,f=1;
	cin>>n;
	string s;
	getline(cin,s);
	getline(cin,s);
	for(int i=0;i<n;i++){
		if(s[i]==' ') {
			//cout<<"a1";
			if(count>=a){
			 a=count;
			 }
			 f=0;
			count=0;

		}
		//cout<<"a"<<i<<s[i];

		if(s[i]>=65&&s[i]<=90){
			count++;

			}
	}
	if(f==1) cout<<count<<endl;
	else cout<<a<<endl;
}

/*
I know I can't take one more step towards you
'Cause all that's waiting is regret
Don't you know I'm not your ghost anymore
You lost the love I loved the most
I learned to live, half alive
And now you want me one more time
Who do you think you are?
Runnin' 'round leaving scars
Collecting your jar of hearts
And tearing love apart
You're gonna catch a cold
From the ice inside your soul
So don't come back for me
Who do you think you are?
I hear you're asking all around
If I am anywhere to be found
But I have grown too strong
To ever fall back in your arms
I've learned to live, half alive
And now you want me one more time
*/
//-----------------------------------------------BAHUT HO GYI BAKCHODI,AB CODING HOGI----------------------------------------------------//

#include <bits/stdc++.h>

using namespace std;

#define speed ios::sync_with_stdio(false)
#define ll long long int
#define pb push_back
#define mp make_pair
#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define INF 999999999
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define _gcd __gcd
#define eps 1e-9
char s[10000];
int main(){
	cin.tie(0);
	ll n;
	cin>>n;
    scanf("%s",s);
	ll ans=0,res=0;
	for(ll i=0;i<n;i++){
		if(s[i]!=' '){
			if(s[i]>='A'&&s[i]<='Z')res++;
		}else {
			ans = max(ans,res);
			res =0;
		}
	}
	ans = max(ans,res);
	cout<<ans;
   return 0;
}

#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;

    char arr[n];
    cin >> arr;

    int ans = 0;
    int a = 0;

    for(int i=0; i<n; i++){
        if(arr[i] < 91 && arr[i] > 64){
            a++;
            if(n == 24){
                int u= arr[i];
                cout << a << " " << arr[i] << " " << u << endl;
            }
        }else if(arr[i] == 32){
            ans = max(ans, a);
            a = 0;
        }
    }
    cout << max(ans, a);
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int mx=0,count=0,n,l,i;
    string s;

    cin>>n;
    getline(cin , s ) ;
    cin.ignore() ;

        l=s.size();
        for(i=0;i<l;i++)
        {
            if(s[i] == ' ' )
                count = 0 ;
            else
            if(s[i]>='A' && s[i]<='Z')
            {
                count++;
            }
            mx=max(mx,count);
         }
                    cout<<mx<<endl;
                    return 0;

}

#include<bits/stdc++.h>
#define NN 210

using namespace std;

char s[NN];

int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n;
	cin>>n;
	cin>>s;
	int ans=0, cnt=0;
	for(int i=0; i<n; i++) {
		if(s[i]==' ') {
			ans=max(ans, cnt);
			cnt=0;
			continue;
		}
		if(s[i]>='A' && s[i]<='Z') cnt++;
	}
	ans=max(ans, cnt);
	cout<<ans<<endl;

	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include "stdio.h"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef size_t st;
typedef unsigned int ui;

const int inf = (int)(1e9 + 7);
const ll INF = (ll)(10e18 + 7);
const ld eps = (ld)(1e-9);
const int MOD = (int)(1e9 + 7);

#define endl '\n'
#define mp make_pair
#define pb push_back

const int MaxN = (int)(1 * 1e6 + 10);
const int MaxM = (int)(1 * 1e6 + 10);

void solve();

int main()
{
	//std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	solve();
	return 0;
}

//  == Solution == //

void solve()
{
	int n;
	cin >> n;
	string s;
	int ans = 0, cnt = 0;
	while (cin >> s)
	for (ui i = 0; i < s.length(); ++i) {
		if (s[i] == ' ') {
			ans = max(ans, cnt);
			cnt = 0;
		}
		else if (isupper(s[i]))
			cnt++;
	}
	ans = max(cnt, ans);
	cout << ans << endl;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
char c;
int n,g,d;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		c=getchar();
		if(c==' ')d=max(d,g),g=0;
		if(c>=65&&c<=90)g++;
	}
	d=max(d,g);
	cout<<d;

	return 0;
}

#include <conio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iostream>
#include <Windows.h>
#include <stdlib.h>
using namespace std;

int main()
{
	int n;
	scanf("%d", &n);

	int result = 0;
	int count = 0;
	char str[205];
	cin >> str;
	for (int i = 0; i < 205; i++)
	{
		if (str[i] >= 'A' && str[i] <= 'Z')
		{
			count++;
			if (count > result)
				result = count;
		}
		if (str[i] == ' ')
			count = 0;
	}
	cout << result;
	//_getch();
	return 0;
}

#include <iostream>
using namespace std;

int main()
{
    int n;char c[200];int a = 0,b = 0;
    cin >> n;
    cin >> c;
    for (int i = 0; i < n; ++i) {
        if (c[i] != ' ') {
            if (c[i] >= 'A' && c[i] <= 'Z') {
                a++;
            }
            if (b < a) {
                b = a;
            }
        } else {
            a = 0;
            continue;
        }
    }
    cout << b;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
char s[205];
int main()
{
    int n;
    scanf("%d",&n);
    gets(s);
    int num=0,ans=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=' ')
        {
            if(s[i]>='A'&&s[i]<='Z')
            {
                num++;
            }
        }
        else
        {
            ans=max(ans,num);
            num=0;
        }
    }
    printf("%d\n",ans);
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,j=0,k=0;
char m[1000];
cin>>n;
cin>>m;
for(i=0;i<=n;i++)
{
    if(m[i]>64&&m[i]<91)
    j++;
    if(m[i]==' '||m[i]=='\0')
      if(k<j)
      k=j;
}

  cout<<k;
    return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pi acos(-1.0)
#define rf freopen("in.txt", "r", stdin);
#define ld long double
#define all(v) v.begin(),v.end()
#define push_back push_back
#define ff first
#define ss second
#define ln length()
#define rep(i,a, n) for(int i=a;i<=n;i++)
#define repp(i,a,b) for(int i=a;i<b;i++)
#define s(n) scanf("%d",&n);
#define sl(n) scanf("%lld",&n);
#define sld(n) scanf("%lf", &n);
#define mod 1000000007

using namespace std;

string s;

int main() {  //rf
    ll n, cnt = 0, ans = 0;
    sl(n);
    getline(cin, s);
    for (int i = 0; i < n; i++) {
        if (isupper(s[i])) {
            cnt++;
        }
        else if (s[i] == ' ') {
            ans = max(cnt, ans);
            cnt = 0;
        }
    }
    cout << max(cnt, ans) << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n;scanf("%d", &n);
	string s;
	int mx = 0;
	while(cin >> s){
		int cnt = 0;
		for(char x : s){
			if(isupper(x))cnt++;
		}
		mx = max(mx, cnt);
	}
	cout << mx;
}

#include<bits/stdc++.h>
using namespace std;
int m,n,l;
main(){
cin>>n;

for(int i=0;i<n;i++){
   char c=cin.get();
   if(isupper(c))
    l++;
   if(c==' '){
    m=max(m,l);
    l=0;
   }

}
m=max(m,l);
cout<<m;

}

#include<bits/stdc++.h>
using namespace std;
int main()	{
int n;
cin>>n;
string s;
getline(cin,s);
int max1=0;
int temp=0;
for(int i=0;i<=n;i++){
cout<<s[i];
int  a = (s[i]);
cout<<a<<endl;
cout<<max1<<endl;
if(a>=65 && a<=90){
temp++;
if(temp>max1)
max1=temp;
}
else if(a==32){
temp=0;
}
}
cout<<max(temp,max1);
}

#include <iostream>

using namespace std ;

int main()
{
	string ch ;
	int x=0,y=0;
	int n;

	cin>>n;
	cin.ignore();

	getline(cin,ch);
	//cout<<ch<<endl;

	for(int i=0;i<n;i++)
	{
		if(ch[i]!=' ')
		{//cout<<ch[i]<<" ";
			if(ch[i]<='Z' && ch[i]>='A')
			{
				y++;
				//cout<<"y="<<" "<<y<<endl;
			}
			//cout<<i<<endl;

		}
		if((i==n-1) || (ch[i]==' '))
		{
			if(y>=x)
			{x=y;
			//cout<<"x="<<" "<<x<<endl;
			y=0;
			}
		}
	}
	cout<<x<<endl;

	return 0;
}

#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<string>

using namespace std;

int main(){

	int n,k;
	cin>>n;

    getchar();
    string str,ch;
    getline(cin,str);

	int i=0,count=0;

	while((str[i]<'A' || str[i]>'Z') && i<n)
		i++;

	while((str[i]!=32 && str[i]!=0) && i<n){
		if(str[i]>='A' && str[i]<='Z'){
			count++;
		}
		i++;
	}
	cout<<count<<endl;

}

#include <bits/stdc++.h>

using namespace std;

bool isBig(char a)
{
	if (int(a)>=65 && int(a)<=90)
		return true;
	return false;
}

int main()
{
	string a;
	int n;
	cin>>n;
	cin>>a;
	int volume=0,word_vol=0;

	for (int i=0;i<n;i++)
	{
		if (a[i]!=' ')
		{
			if (isBig(a[i]))
				word_vol++;
			if (word_vol>volume)
				volume=word_vol;
		}
		else
		{
			word_vol=0;
		}
	}

	cout<<volume;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=0,i,ans=0,maxi=0;
    char c,s[1000];
    cin>>n;
    fflush(stdin);
    cin.getline(s,201);
    for(i=0;i<n;i++)
    {
        if(s[i]<='Z' && s[i]>='A')
        {
            //cout<<s[i];
            ans++;
        }
        if(s[i]==' ')
        {
            maxi=max(ans,maxi);
            ans=0;
        }
    }
    cout<<ans;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m=0,i,n,c=0;
    cin>>n;
    char s[201];
    cin>>s;
    for(i=0;i<=n-1;i++)
    {
        if(s[i]>='A' && s[i]<='Z')
        {
            c++;
        }
        if(s[i]==' ' || i==n-1)
        {
             if(m<c)
        {
            m=c;

            c=0;
        }
        }
    }
    cout<<m<<endl;

}

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
int main(){
int x=0,n,i,j=0,m=0;
string s,p;
//cin>>n;
getline(cin,p);
getline(cin,s);
//cout<<s;
for(i=0;i<s.size();i++){
if(s[i]>='A' && s[i]<='Z'){
j++;
//cout<<s[i]<<" "<<i<<endl;
}

else if(s[i]==' '){
    x=1;
    if(j>m)m=j;
    //cout<<m<<j<<endl;
    j=0;
}}
if(x==0)cout<<j<<endl;
else
cout<<m<<endl;
return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,count=0;
    cin>>n;
    char st[n];
    for(i=0; i<n; i++)
    {
        cin >> st[i];
        if(st[i] >= 'A' && st[i]<='Z')
        {
            count++;
        }
    }
   cout<<count<<endl;
    return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main() {
	int i,j,k=0,c=0,n,max=0;
	string s;
	cin>>n;
	cin>>s;
	int a[n]={0};
	for(i=0;i<n;i++)
	{
		for(j='A';j<='Z';j++)
		{
			if(s[i]==j)
				c++;
		}
		if(s[i]==32)
		{
			a[k]=c;
			k++;
			c=0;
		}
	}
	if(k==0)
		cout<<c;
	else if(k>0)
	{
		for(i=0;i<k;i++)
		{
			if(a[i]>max)
				max=a[i];
		}
		cout<<max;
	}
	return 0;
}

#include<iostream>
#include<algorithm>
#include <bits/stdc++.h>
using namespace std;

main()
{
    int n, maks=0;
    cin>>n;
    string s;
    while(cin>>s)                   //TU SZUKA� B��DU
    {
        int k=0;
        for(int i=0; i<=s.size(); i++)
        {
            if(isupper(s[i]))
            {
                k++; maks = max(maks, k);
            }
        }

        cout<<maks<<endl; return 0;

        //l=l+s.size();

        //if(l>=n) {cout<<maks<<endl; return 0;}
        //else if(l<n) {cout<<maks<<endl; return 0;}
        //delete else if(s.size()==1){cout<<1<<endl; return 0;}
    }
}

/*#include <bits/stdc++.h>
using namespace std;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, res = 0;
	cin >> n;
	string s;
	while (cin >> s)
	{
		int cnt = 0;
		for (int i = 0; i < (int) s.size(); ++i)
		{
			if (isupper(s[i])) cnt++;
			res = max(res, cnt);
		}
	}
	cout << res;
}
*/

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n],i,c=0;
    string s;
    fflush(stdin);
    getline(cin,s);
    for(i=0;i<n;i++)
    {
        if(s[i]>='A'&&s[i]<='Z')
            c++;
       // cout<<"Hello";
    }
    cout<<c<<endl;
}

#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int n, s = 0;
    scanf("%d", &n);
    char space = ' ';
    for (int i = 0; i < n; i++)
    {
        char a;

        scanf("%c", &a);
        if (a != space){
        char b = toupper(a);

        if (b == a)
        {
            s ++;
        }
        }
    }

    printf("%d", s);

    return 0;
}

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() { boost
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int n;
    string s;
    cin >> n >> s;

    int cnt = 0, maxCnt = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == ' ') {
            cnt = 0;
        } else {
            if ('A' <= s[i] and s[i] <= 'Z') {
                cnt++;
            }
        }
        maxCnt = max(maxCnt, cnt);
    }

    cout << maxCnt << "\n";

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,j=0,k=0;
char m[1000];
cin>>n;
cin>>m;
m[n]='\0';
for(i=0;i<=n;i++)
{
    if(m[i]>64&&m[i]<91)
    j++;
   else if(m[i]==' '||m[i]=='\0')
      if(k<j)
      k=j;
}

  cout<<k;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio();
    cin.tie(0); cout.tie(0);
    int n;
    string s;
    cin >> n;
    int ans = 0;
    cin >> s;
        int cnt = 0;
        for(int i = 0; i < s.size(); ++i){
            if(s[i] >= 'A' && s[i] <= 'Z'){
                ++cnt;
            }
        }
        ans = max(ans, cnt);

    cout << ans << '\n';
    return 0;
}

#include<iostream>
#include<algorithm>
using namespace std;

main()
{
    int n, k=0, maks=0, l=0;
    cin>>n;
    string s;
    while(cin>>s)
    {
        for(int i=0; i<s.size(); i++)
        {
            if(int(s[i])>='A' && int(s[i]<='Z'))
            {
                k++; maks = max(maks, k);
            }
        }

        l=l+s.size();

        if(l>=n) cout<<maks<<endl; return 0;
    }

    //cout<<n<<" "<<s<<endl;
}

//
//  main.cpp
//  TextVolume
//
//  Created by Meng Xu on 1/11/18.
//  Copyright © 2018 MengXu. All rights reserved.
//

#include <iostream>
#include<string>
using namespace std;

int main() {
    int n;
    cout << "input length:" << endl;
    cin >> n;
    string text;
    cout << "input text:" << endl;
    getline(cin,text);
    getline(cin,text);
    int volume = 0;
    int maxV = 0;
    for(int i = 0; i < n; i++){
        char temp = text[i];
        if (temp != ' '){
            if(temp <= 'Z' && temp >= 'A'){
                volume ++;
                if (maxV < volume)
                    maxV = volume;
            }
        }else
            volume = 0;
    }
    cout << maxV << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=0,p=0;
    cin>>n;

    string s;
    getline(cin,s);
     getchar();
//    for(int i=0;i<n;i++)
//    {
//        cin>>s[i];
//    }
   // int l=s.size();
    for(int i=0;i<n;i++)
    {
        //Sgetchar();

       if(s[i]>='A' && s[i]<='Z')
       {
           c++;
       }
       if(s[i]==' ')
       {
       //cout<<"K";
          if(p<c)
          {
              p=c;
              c=0;
          }
          else
            c=0;
       }
    }
 if(p>c)
       {
        cout<<p;
       }
        else
            cout<<c;
    return 0;
}

#include <iostream>
#include <string>
using namespace std;

int main() {
    char s[202] = {' '};
    int n;

    cin >> n;

    getchar();
    scanf("%[^\n]",s);

    int flag = 0;
    int max = 0;
    int hah=0;
    for(int i = 0; i < n; ++i){

        if(i==n-1){
            if(max <= flag){
                max = flag;
            }
        }
        if(s[i] == ' '){
            if(max <= flag){
                max = flag;
            }
            hah=1;
            flag = 0;
        }

        else if(s[i] >= 65 && s[i] <= 90){
            flag++;
        }

        else{
            continue;
        }
    }

    if(hah == 0){
        max = flag;
    }

        cout<<max<<endl;

    return 0;
}

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
int main(){
int x=0,n,i,j=0,m=0;
string s,p;
//cin>>n;
getline(cin,p);
getline(cin,s);
//cout<<s;
cout<<s[s.size()-1];
for(i=0;i<s.size();i++){
if(s[i]>='A' && s[i]<='Z'){
j++;
//cout<<s[i]<<" "<<i<<endl;
}

else if(s[i]==' '){
    if(j>m)m=j;
    //cout<<m<<j<<endl;
    j=0;
}}
if(j>m)cout<<j<<endl;
else
cout<<m<<endl;
return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	char g[200],a[1];
	int i,x,m=0,sum=0;
	scanf("%d",&x);
	gets(a);
	gets(g);
	for(i=0;i<x;i++)
	{
		if(g[i]>='A'&&g[i]<='Z')
			{
				sum++;
			}
		if(g[i]==32)
		{
			if(sum>m)
			m=sum;
			sum=0;
		}
 	}
if(m==0)
m=sum;
printf("%d",m);
return 0;
}

#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define r_0 return 0
#define fr first
#define se second
#define Hi ios_base::sync_with_stdio(0);
using namespace std;
map<ll,ll>mp;
ll int b,c, n,m,x,cnt;
string s,o,name="shohrukh";
vector<char>v;
vector<string>ve;
pair<int,int>p;
set<int>se;
int main()
{
    Hi
    cin >> n;
    getline(cin,s);
    for ( int i=0; i<s.size(); i++ )
    {
        if ( s[i] >='A' and s[i] <='Z' )
        {
            cnt ++;
        }
    }
    cout << cnt ;
}

#include<iostream>
#include<vector>
#include<string>

int main(){
    int n;
    int maxv=0;
    std::vector<char> word;
    std::cin >> n;
    for(int i =0; i < n; i++){
        char a;
        std::cin >> std::noskipws >> a;
        std::cout << a;
        if(a >= 'A' && a <= 'Z')
        {
            word.push_back(a);
        }
        if(a == ' '){
            if(maxv < word.size()){
                maxv = word.size();
            }
            word.clear();
        }
    }
    if(maxv == 0){
        if(maxv < word.size()){
                maxv = word.size();
            }
            word.clear();
    }
    std::cout << maxv << std::endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,ans=0,o=0;
    char s[500];
    cin>>a>>s;
    for(int i=1;i<=a;i++){
        if(s[i]-'@'>=1&&s[i]-'@'<=26)
            o++;
        if(s[i]==' '){
            if(o>ans)
                ans=o;
            o=0;
        }
    }
    cout<<ans<<"\n";
	return 0;
}

#include <stdio.h>
#include <algorithm>
#define ll long long
using namespace std;

int main() {
    int n, ctr=0;
    scanf("%d", &n);
    char s[n+1];
    getchar();
    scanf("%[^\n]", s);
    int ans=0;
    for (int i=0;s[i]!='\0';i++) {
        if (s[i]>='A'&&s[i]<='Z') {
            ctr++;
        }
        else {
            ans=max(ans, ctr);
            ctr=0;
        }
    }
    printf("%d\n", max(ans, ctr));
}

#include<bits/stdc++.h>

using namespace std;

int n,dem=0,maxx=0;
string s;

int main()
{
    cin>>n;
    fflush(stdin);
    getline(cin,s);
    for(int i=0;i<n;i++)
    {
        if(s[i]==' ')
        {
            dem=0;
        }
        else if(s[i]>='A' && s[i]<='Z')
        {
            dem++;
        }
        if(dem>maxx) maxx=dem;
    }

    cout<<maxx;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int maxn = 205;
char s[maxn];
int main()
{
    int n;
    scanf("%d", &n);
    int num = 0, ans = -9;
    //scanf("%[^\n]", s);
    while(~scanf("%s", s))
    {
        ans=0;
        int len=strlen(s);
        for(int i = 0; i<len; i++)
        {
                if(s[i] >= 'A' && s[i] <= 'Z')
                {
                    num++;
                }
        }
        ans = max(ans, num);
    }
    printf("%d\n", ans);
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

const int MAXN = 1e3 + 10;
char str[MAXN];

int main(void){
    int n;
    scanf("%d", &n);
    gets(str);
    int sol = 0, cnt = 0;
    for(int i = 0; i < strlen(str); i++){
        if(str[i] >= 'A' && str[i] <= 'Z') cnt++;
        else if(str[i] == ' '){
            sol = max(sol, cnt);
            cnt = 0;
        }
    }
    sol = max(sol, cnt);
    printf("%d\n", sol);
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define fr(i,x) for( int i=0;i<(x);i++)
#define endl '\n'
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main()
{
    int t,c=0;
    cin>>t;
   string s;
   getline(cin, s);
     int upper=0,ans=0;
   for (int i = 0; i <t; i++)
    {
      if(s[i]>='A' && s[i]<='Z')
       {
          upper++;
          ans=max(upper,ans);
        }
      else if(s[i]==' ')
       {
        upper=0;
       }
    }

     cout<<ans;
    return 0;

}

/*
  Shashank Sharma
  Shashank129
*/

#include <bits/stdc++.h>
using namespace std;
#define minpq priority_queue <int, vector<int>, greater<int> >;
#define maxpq  priority_queue <int>;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
const int mod = 1e9+7, N = 1e5 + 10;

bool vol(char c) {
    if(c >= 'A' && c <= 'Z') {
        return true;
    }
    return false;
}

void solve() {
    int n, c = 0, maxi = -1;
    string s;
    cin >> n >> s;
    for(int i = 0; i < n; i++) {
        if(vol(s[i])) {
            c++;
        }
        if(s[i] == ' ') {
            maxi = max(maxi, c);
            c = 0;
        }
    }
    maxi = max(maxi, c);
    cout << maxi;
    return;
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int test = 1;
    //cin >> test;
    while(test--) {
        solve();
    }
}

#include <iostream>
#include <string>

using namespace std;

int main() {
	int n, m = 0, c = 0;
	cin >> n;
	string inp;
	getline(std::cin, inp);

	for (int i = 0; i < n; i++)
	{
		if (inp[i] >= 'A' && inp[i] <= 'Z')
			c++;
		if (inp[i] == ' ' && c > m)
		{
			m = c;
			c = 0;
		}
	}
	cout << m;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int mx=0,count=0,n,l,i;
    string s;

cin>>n;
while(cin>>s)

    {    count=0;
        l=s.size();
        for(i=0;i<l;i++)
        {
            if(s[i]>='A' && s[i]<='Z')
            {
                count++;
            }
            mx=max(mx,count);
                    }
                    cout<<mx<<endl;
                    return 0;
    }

}

#include <iostream>
#include <string>
using namespace std;
/*
int main() {
	int N;
	cin >>N;
	int max=0;
	string s;
	while (cin >>s)
	{
		int curr=0;
		for (char c: s)
			if (c>='A'&&c<='Z')
				curr++;
		if (curr>max)
			max = curr;
	}
	cout <<max <<endl;
	return 0;
}*/

int main() {
	int N;
	cin >>N;
	int curr=0,max=0;
	for (int i=1;i<=N;i++)
	{
		char c;
		c=cin.get();
		if (c>='A'&&c<='Z')
			curr++;
		else if (c==' ')
		{
			if (curr>max)
				max = curr;
			curr=0;
		}
	}
	if (curr>max)
		max = curr;
	cout <<max <<endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
bool kt1(char c)
{
    return c>='A' && c<='Z';
}
int main()
{
    string str;
    int m;
    cin>>m;
    fflush(stdin);
    getline(cin,str);
    int maxx=0, cnt=0;
    for(int i=0; i<str.size(); i++)
    {
        if(kt1(str[i]))
        {
            cnt++;

        }
        if(str[i]==' ')
        {
            if(cnt>maxx)
            {
                maxx=cnt;
            }
            cnt=0;
        }
    }
    cout<<cnt;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

#define lli            long long int
#define ull            unsigned long long int
#define pb             push_back
#define bp             pop_back
#define mp             make_pair
#define rev            reverse
#define max3(a,b,c)    max(a,max(b,c))
#define max4(a,b,c,d)  max(max3(a,b,c),d)
#define min3(a,b,c)    min(a,min(b,c))
#define min4(a,b,c,d)  min(min3(a,b,c),d)
#define all(v)         v.begin(),v.end()
#define lol            return 0

int main()
{
	int n, v, i, ck=0;
     char s[1001];
	scanf("%d",&n);
	while (scanf("%s",&s)!=EOF)
	{
		for (i=0;i<strlen(s);i++)
		{
			if (s[i]>='A' && s[i]<='Z')
				ck++;
		}
		v=max(v,ck);
	}
	printf("%d", &v);
	lol;
}

// Example program
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string s;
  cin >> s;
  int su = 0;
  int n = s.size();
  for (int i = 0;i<n;++i)
  {
      if(s[i]>='A' || s[i]<='Z')
      su++;
  }
  cout << su;
}

/*input
7
NonZERO
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long t,q,m,k,h,ans=0,sum=0,p,x,y;
	string s;
	cin>>n>>s;
	stringstream ss(s);
	while(ss>>s){
		set<char> st;
		for(int i=0;i<s.size();++i)
			if(s[i]>='A'&&s[i]<='Z')
				st.insert(s[i]);
		ans=max(ans,(long long)st.size());
	}
	cout<<ans;
}

#include<bits/stdc++.h>
using namespace std;
int main ()
{
     int m=0,k=INT_MIN,n,ck=0;
     string s;
    cin>>n;
    getline(cin,s);
    getline(cin,s);
    for(int i=0;i<s.size();i++){
        if(s[i]>='A' && s[i]<='Z'){
          m++;
        }
        if(s[i]==' '){
         k=max(m,k);
         m=0;
         ck=1;
        }

    }
    if(ck==0){
        cout<<m<<endl;
    }
     else cout<<k<<endl;
}

#include<iostream>
#include<string>
using namespace std;
int NumberOfVolume(string word)
{
	int i = 0;
	int Cmp = -1e6;
	int count = 0;
	while (i < word.size())
	{
		count = 0;
		while (word[i] != ' ' && word[i] != '\0')
		{
			if (isupper(word[i]))
			{
				count++;
			}
			i++;
		}
		Cmp = max(Cmp, count);
		i++;
	}
	return Cmp;
}
int main()
{
	int n;
	cin >> n;
	char A[5002];
	scanf("%s", A);
	cout<<NumberOfVolume(A);
}

#include <iostream>
using namespace std;
char s[201];
int main() {
    int n;
    cin >> n;
    cin.get();
    cin.getline(s, n+1);
    int sum = 0;
    for(int i = 0; i < n; i++) {
        if(s[i]>='A' && s[i] <= 'Z') {
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[201];
	int i,count=0,max=0,v=0;
	gets(a);
	for( i=0;i<strlen(a);i++)
	{
		if(isupper(a[i]))
		count++;
		else if(a[i]==' ')
		{
			if(count>max)
			max=count;
			count=0;
		}
	}
	if(count>max)
	max=count;
	cout<<max<<endl;
	return 0;

}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char s[n];
    scanf(" %[^\n]",s);
    int c=0;
    for(int i=0;i<n;i++){
        if(s[i]==' ')c=0;
        if(s[i]>='A' && s[i]<='Z')c++;
    }
    cout << c<<endl;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main ()
{
       int k, m;
       m = 0;
       cin >> k;
       string l;
       getline (cin, l);
       for (int i = 0; i < l.size(); i++)
       {
              if (i == 0 or l[i] == ' ')
                     m = max (m, k), k = 0;
              if (l[i] >= 'A' and l[i] <= 'Z')
                     k++;
       }

       cout << m;

       return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main(){
   char ch;
   int n,max=0;
   int o=0;
   cin >> n ;
   ch = getchar();
   for(int i=0;i<n;i++){
        ch = getchar();
        if( ch>='A' && ch<='Z'){
            o++;
        }
        if(ch==' '){
            if(o>max){
                max=o;
            }
            o=0;
        }
   }
   if(max==0) max=o;
   cout << max << endl;
   cout << max << endl;
}

#include<bits/stdc++.h>
using namespace std;
int n;
int ans;
char a[10001];
int main()
{
   cin>>n;
   for(int i=1;i<=n;i++)
     {
     	cin>>a[i];
     	if(a[i]<='Z'&&a[i]>='A')
     	  ans++;
	 }
   cout<<ans;
   return 0;
}

#include<iostream>
#include<ctype.h>
using namespace std;
int main(){
int c=0,a;
cin >>a;
string s , q ;
getline(cin , q );
getline(cin , s );
for(int z=0;z<a;z++){
if (s[z] >= 'A' && s[z] <= 'Z' )
c++;
}

cout<<c<< endl;
return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main(){
    freopen("input.txt","r",stdin);
    int n; cin>>n;
    int cnt=0, ans=-1;
    for(int i=0; i<n; i++){
        char c; cin>>c;
        if(c==' '){
            ans=max(ans,cnt);
            cnt=0;
        } else if(c==toupper(c)) cnt++;
    }
    cout<<max(ans,cnt);
}

#include<iostream>
#include<cstdlib>
#include<cstring>
using namespace std;
main()
{
     char str[10000];
     int i,j,count=0,l=0,n;
     cin>>n;
     gets(str);
     for(i=0;i<n;i++)
     {
               if(str[i]>='A' &&str[i]<='Z')
               count++;
          if(str[i]<'A'||i+1==n)
          {
               if(l<count)
               {
                    l=count;
                    count=0;
               }
          }

     }
     cout<<l;
     return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main()
{
	int i,m=0,c=0;
	cin >> i;
	string s1;
	cin >> s1;
	for(int n=0;n<i;n++)
	{
		if ((s1[n] <= 'Z') && (s1[n] >='A'))
			m++;
		if (s1[n] == ' ')
			m = 0;
		if (m > c)
			c = m;
	}
	cout << c << endl;
	return 0;
}

#include <iostream>
#include <string>
using namespace std;
int main(){
	int n,maxi=0,counti=0;
	cin>>n;
    string s;
    getline(cin,s);
    for(int i=0;i<n;i++)
  {
  	if(isupper(s[i]))
	{
	   counti++;
    }
  	if(s[i]==' ')
  	{
  		maxi=max(maxi,counti);
  		counti=0;
	}
  }
  maxi=max(maxi,counti);
  cout<<maxi+1;
    return 0;
}

/* Text Voolume
 * 837a
 * cf
 */

#include<bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int len, ma = -1e10;
    string t;
    cin >> len;
    while(cin >> t) {
        cout << t  << " is cureent \n";
        int count = 0;
        for(int i = 0; i < t.length(); ++i) {
            if(t[i] >= 'A' and t[i] <= 'Z') {
                count++;
            }
            ma = max(count, ma);
        }
    }

    cout << ma << "\n";
    return 0;
}

#include <iostream>
#include <cstring>
using namespace std;
int main (){
	int n, ans=0, maxv=0;
	string s;
	cin>>n;
	while (cin>>s){
		for(int i=0;i<s.size();i++)
			if(s[i]>='A'&&s[i]<='Z') ans++;
		maxv=max(maxv,ans);
	}
	cout<<maxv<<endl;
	return 0;
}

#include<bits/stdc++.h>

using namespace std;
#define ll long long int
#define feb(i,n) for(int i=0;i<n;i++)
#define len(a) a.length()
int main() {
   int k=0,n=0,m;
   cin>>m;
   string s;
   cin.ignore();
   getline(cin,s);
   for(int i=0;i<m;i++){
     if(s[i]>='A'&&s[i]<'Z'){
     k++;}
     if(s[i]==' '){
      n=max(n,k);
        k=0; }
   }
   n=max(n,k);

   cout<<n<<endl;
   }

#include<iostream>
#include<stdio.h>
#include<string>
#include<cstring>
using namespace std;

int main()
{
	int n;
	cin >> n;
	string a;
	int ans = 0;
	while (cin >> a) {
		int t = 0;
		for (int i = 0; i < a.length(); i++) {
			if (a[i] >= 'A'&&a[i] << 'Z') {
				t++;
			}
		}
		if (t > ans)ans = t;
	}
	cout << ans << endl;
	return 0;
}

#include <iostream>
#include <cstring>
using namespace std;
int main(){
    string s;
    int x,amt,spaceamt,a;
    amt=0;
    a=0;
    spaceamt=0;
    getline (cin,s);
    for (x=0;x<s.length();x++){
        if (s[x]<'a'){
            amt++;
            if (s[x]<'A'){
            	amt--;
            	a++;
            }
        }
    }
    cout<<amt;
    return 0;
}

#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
char s[205];
int main()
{
    int n;
    while(~scanf("%d",&n)){
        int ans = 0;
        scanf("%s",s);
        for(int i = 1; i <= n; i++){
            if(s[i] >= 'A' && s[i] <= 'Z') ans++;
        }
        printf("%d\n",ans);
    }
}

#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    int n,c=0;
    cin>>n;
    char ch[n];
    for(int i=0;i<n+1;i++)
    {
        scanf("%c",&ch[i]);
        if(ch[i]==' ')
            break;
        if(ch[i]>='A' && ch[i]<='Z')
            c++;
    }
    cout<<c;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main () {
    int n, vol = 0, m = 0;
    cin >> n;
    string s;

    cin >> s;
    for (int i = 0; i < n; i++) {
        if ( isspace(s[i])) {
            m = max(vol, m);
            vol = 0;
            continue;
        }
        if ( int(s[i]) >= 65 & int(s[i]) < 90 ) {
            vol++;
        }
    }
    cout << max(m, vol) << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int s[200+10];
char a[200+10];
int main()
{
	int n;
	cin>>n;
	getchar();
	for(int i=0;i<n;i++) scanf("%[^\n]",a);
	//cin.get(a,n);//���մ��ո���ַ���
	int flag=0,m=0;
	for(int i=0;i<n;i++){
		if(a[i]==' ') {
			flag=1;//�ո�
			m=i;//���һ���ո�
		}
	}
	int k=0,j=0;
	if(flag==0){//��һ������
		for(int i=0;i<n;i++){
			if(a[i]>='A'&&a[i]<='Z'){
				k+=1;
			}
			//cout<<"i: "<<i<<" k: "<<k<<endl;
		}
		cout<<k<<endl;
	}
	if(flag==1){//24 Harbour Space UniversitY
		int ans=0;
		for(int i=0;i<n;i++){
			if(a[i]>='A'&&a[i]<='Z') k++;
			if(a[i]==' '){
				s[j]=k;cout<<"i "<<i<<" s[] "<<s[j]<<endl;
				ans=max(ans,s[j]);
				j++;k=0;
			}
			if(i==n-1){
				s[j]=k;cout<<"i "<<i<<" s[] "<<s[j]<<endl;
				ans=max(ans,s[j]);
				j++;k=0;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{

        int n;
        cin >> n;
        string s;
        getline(cin, s);
        getline(cin, s);
        int ans = 0;
        int tmp = 0;
        for(int i = 0; i < s.size(); i++)
        {
            if('A' <= s[i] and s[i] <= 'Z')
                tmp++;
            else if(s[i] == ' ')
            {
                ans = max(ans, tmp);
                tmp = 0;
            }
        }
        //ans = max(ans, tmp);
        cout << ans << endl;
        return 0;

}

#include<iostream>
#include<iterator>
#include<algorithm>
#include<math.h>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<map>
#include<bitset>
#include<set>
#include<deque>
#include<queue>
#include<list>
#define ln 1000005
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
using namespace std;
string str;
void process(int len){

    vector<char>akash[len];
    int count1=1,ans=0;

    for(int i=0;i<len;i++){

        if(str[i]>='A' && str[i]<='Z'){
            akash[count1].push_back(str[i]);
        }
        if(str[i]==' '){
            count1++;
        }
    }

    for(int i=1;i<=count1;i++){

        if(akash[i].size()>ans){
            ans=akash[i].size();
        }
    }
    cout<<ans<<endl;

}
int main()
{
    int len;

    cin>>len;
    getchar();
    getline(cin,str);

    process(len);

    return 0;
}

/*  : Om Ganeshaay Namah:

~~~~~~~~~~~~~~~~~~~~~~~~~       All hail l0fty.WhizZ      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is Shreyas Iyer's code! My handle in Codechef, Codeforces,
Hackerrank and all is : shreyasiyer_14.

College: International Institute of Information Technology, Bangalore.

Feel free to send me tips and tricks, since I am a fresher!!
Oh and by the way, you can always challenge me in Counter Strike! I will be glad
to showoff my sniping skills! :P
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

typedef int i;
typedef long int l;
typedef long long int ll;
typedef float f;
typedef long double lf;
typedef char c;

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define s(x) cin >> x
#define s2(x,y) cin >> x >> y
#define p(x) cout << x << endl
#define p2(x,y) cout <<x << y << endl
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define f(i,a,n) for (int i=a;i<n;i++)
#define fl(i,a,n) for (long int i=a;i<n;i++)
#define fll(i,a,n) for (long long int i=a;i<n;i++)

//Code starts Here!

int main(void) {
	FASTER;
	ll n;
	string s;
	ll res = 0;
	cin >> n >> s;
	fll(i,0,s.length()) {
		ll max = 0;
		while (s[i] != ' ' && i < s.length()) {
			if ((int)s[i] >= 65 && (int)s[i] < 97)
				max ++;
			i++;
		}
		if (max > res)
			res = max;
	}
	p(res);
    return 0;
}

#include <iostream>
#include <stdio.h>

using namespace std;

int n, s, mass;

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        char ch;
        scanf("%c", &ch);
        if(ch < 65 || ch > 122)
        {
            if(s > mass) mass = s;
            s = 0;
            continue;
        }
        if(ch >= 65 && ch <= 90) s++;
        mass = s;
    }

    cout << mass + 1 << endl;
}

#include<bits/stdc++.h>
using namespace std;
int ans;
char c;
int main()
{
	while(cin>>c)
		if(c>='A'&&c<='Z')ans++;
	cout<<ans;
	return 0;
}

#include<iostream>
using namespace std;
main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int mx = 0,cm = 0;
    for(int i=0;i<n;i++)
    {
        char a = s[i];
        if(a == ' ')
        {
            mx = max(mx, cm);
            cm = 0;
        }
        else if(isupper(a))
            cm++;
    }
    mx = max(mx, cm);
    cout<<mx<<endl;
}

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

/*string StrNubmber(ll number)
{
string ans = "";
if (number == 1) ans = "1";
else if (number == 2) ans = "2";
else if (number == 3) ans = "3";
else if (number == 4) ans = "4";
else if (number == 5) ans = "5";
else if (number == 6) ans = "6";
else if (number == 7) ans = "7";
else if (number == 8) ans = "8";
else if (number == 9) ans = "9";
else  ans = "0";
return ans;
}

string ToStr(ll number)
{
string ans = "";
while (number / 10 >= 1)
{
ans = StrNubmber(number % 10) + "" + ans;
number /= 10;
}
ans = StrNubmber(number % 10) + "" + ans;
number /= 10;
return ans;
} */

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;
	string s;
	int big = 0;
	int count = 0;
	bool check = false;

	while (cin >> s)
	{
		for (int i = 0; i < n; i++) { if (isupper(s[i])) { ++count; } }
		if (big < count) { big = count; }
		if (!check) { check = true; }
		count = 0;
	}

	if (check) cout << big;
	else cout << count;

	//system("pause");
	return 0;
}
/*Otabek*/

#include <bits/stdc++.h>
#define task "837a"
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
		freopen(task".inp", "r", stdin);
		freopen(task".out", "w", stdout);
	#endif
	string s;
	getline(cin, s);
	getline(cin, s);

	int cnt=0;
	for (int i=0; i<s.length(); ++i)
		if (s[i]>='A' && s[i]<='Z') cnt++;
	cout<<cnt;
	return 0;
}

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int n, ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		char s;
		s = getchar();
		if (s >= 'A' && s <= 'Z') {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

    #include<cstdio>
    #include <vector>
    #include <algorithm>
	   #include <bits/stdc++.h>
      #include <cmath>

    using namespace std;
    int main() {
      int n;
      int output = 0;
      cin>>n;
      string line;
      cin>>line;
      for(int i = 0 ;i<n ; i++){
        if(line[i]>64 && line[i]<91){
          output ++;
        }
      }
      cout << output;
    }

#include <bits/stdc++.h>

using namespace std;
char s[500];
int dem=0,n,res=0;
int main()
{
    cin>>n;
    fflush(stdin);
    gets(s);
    for (int i=0;i<n;i++){
        if ((int)s[i]>=65&&(int)s[i]<=90) dem++;
        if ((int)s[i]==32) {
            if (dem>res) res=dem;
            dem=0;
        }
    }
    cout<<res;
    return 0;
}

#include<iostream>
#include<algorithm>
#include <bits/stdc++.h>
using namespace std;

main()
{
    int n, k=0, maks=0, l=0;
    cin>>n;
    string s;
    while(cin>>s)
    {
        for(int i=0; i<=s.size(); i++)
        {
            if(isupper(s[i]))
            {
                k++; maks = max(maks, k);
            }
        }

        cout<<maks<<endl; return 0;

        //l=l+s.size();

        //if(l>=n) {cout<<maks<<endl; return 0;}
        //else if(l<n) {cout<<maks<<endl; return 0;}
        //delete else if(s.size()==1){cout<<1<<endl; return 0;}
    }
}

/*#include <bits/stdc++.h>
using namespace std;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, res = 0;
	cin >> n;
	string s;
	while (cin >> s)
	{
		int cnt = 0;
		for (int i = 0; i < (int) s.size(); ++i)
		{
			if (isupper(s[i])) cnt++;
			res = max(res, cnt);
		}
	}
	cout << res;
}
*/

#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long ll;

int main() {
	//ios::sync_with_stdio(false);

	string s;
	ll ans = 0,n;

	cin >> n;
	getchar();
	getline(cin,s);

	for (register int i = 0; i <= s.size(); ++i) {
		if (s[i] >= 'A' && s[i] <= 'Z') ++ans;
		else if (s[i] == ' ') ans = 0;
	}

	cout<<ans;

	return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n,a,b,i;
	cin>>n;
	string s;
	a=0;b=0;
	getline(cin,s);
	getline(cin,s);
	for (i=0;i<n;i++){
		if (s[i]<91) b++;
		else
			if (s[i]==' '){
				if (b>a) a=b;
				b=0;
			}
	}
	if (b>a) a=b;
	cout<<a;

}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<iomanip>
using namespace std;
// cout <<setprecision(6) <<std::fixed<<
int main(int i,int j)
{
    char s[200];
    int n;
    cin>>n>>s;
    int ans=0,cnt=0;
    for(i=0;i<n;i++)
    {
        if(s[i]==' ')cnt=0;
        if(s[i]>='A'&&s[i]<='Z')cnt++;
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
main()
{
	string mystr;int c=0;int arr[50]={},k=0;int max=0;
	 getline (cin, mystr);
	 for(int i=0;i<mystr.length();i++)
	 {
	 	if(mystr[i]>=65&&mystr[i]<=90)
	 	{
	 		c++;
		 }
		 else if(mystr[i]==32)
		 {
		 	arr[k++]=c;
		 	c=0;

		 }
	 }

		 	arr[k++]=c;
		 	c=0;

	 for(int i=0;i<k;i++)
	 {
	 	if(max<arr[i])
	 	{
	 		max=arr[i];
		 }
	 }
	 cout<<max;
}

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
   int n;
   cin>>n;
   string str;
   cin>>str;
   int cnt=0;
   int ans=0;
  for(int i=0;i<n;i++)
  {
     if(str[i]>='A' && str[i]<='Z')
       cnt++;
       else
       if(str[i]==' ')
        ans=max(ans,cnt);
  }
  cout<<ans;
}

#include<iostream>
#include<stdio.h>
#include<cstring>
using namespace std;

char s[205];
int main()
{
	int n;
	cin >> n;
	memset(s, 0, sizeof(s));
	scanf("%s", &s);
	int ans = 0;
	int len = strlen(s);
	for (int i = 0; i < len; i++) {
		int t = 0;
		for (int j = i; j < len; j++) {
			if (s[j] != ' ') {
				if ('A' <= s[j] && s[j] <= 'Z') {
					t++;
					if (ans < t)
						ans = t;
				}
			}
			else {
				if (ans < t) {
					t = ans;
				}
				i = j + 1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
char s[205];
int main()
{
    int n;
    scanf("%d",&n);
    gets(s);
    int num=0,ans=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=' ')
        {
            if(s[i]>='A'&&s[i]<='Z')
            {
                num++;
            }
        }
        else
        {
            ans=max(ans,num);
            num=0;
        }
    }
    printf("%d\n",ans);
}

#include<bits/stdc++.h>
using namespace std;
int main()
{

	int n,ans=0,mx=0;

	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<n;i++)
	{
		if(isupper(s[i]))
		{
			ans++;

			if(s[i+1]!=' ')
			{
				mx=max(ans,mx);
			}
		}
		else if(islower(s[i]))
		{
			continue;
		}
		else
		{
			ans=0;
		}
	}
	cout<<mx<<endl;

}