let str ;
while(str = readline()){
  //+? 禁止贪婪
  let res = str.match(/[A-Z]+?/g);
  if(res){
    console.log(res.length)
  }else{
    console.log(0)
  }

}