#include <bits/stdc++.h>
using namespace std;
int main() {
  int iLength;
  int iR = 0;
  int iVol = 0, iAns = 0;
  string sText;
  cin >> iLength;
  cin.ignore();
  getline(cin, sText);
  while (sText[iR] != '\0') {
    if (sText[iR] != ' ') {
      if (sText[iR] >= 65 && sText[iR] <= 90) {
        iVol++;
      }
    } else {
      if (iAns <= iVol) {
        iAns = iVol;
      }
      iVol = 0;
    }
    iR++;
  }
  if (iAns <= iVol) {
    iAns = iVol;
  }
  cout << iAns;
  return 0;
}
