#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
inline void yes() { cout << "yes" << endl; }
inline void Yes() { cout << "Yes" << endl; }
inline void YES() { cout << "YES" << endl; }
inline void no() { cout << "no" << endl; }
inline void No() { cout << "No" << endl; }
inline void NO() { cout << "NO" << endl; }
inline void possible() { cout << "possible" << endl; }
inline void Possible() { cout << "Possible" << endl; }
inline void POSSIBLE() { cout << "POSSIBLE" << endl; }
inline void impossible() { cout << "impossible" << endl; }
inline void Impossible() { cout << "Impossible" << endl; }
inline void IMPOSSIBLE() { cout << "IMPOSSIBLE" << endl; }
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;
}
