无脑用正则表达式就完事了

import re
while 1:
    try:
        a = input()
        b = re.findall('[A-Z]',a)
        print(len(b))
    except:
        break