利用字符串的s.isupper()方法判断是否为大写字母

while True:
    try:
        s = input()
        count=0
        for i in s:
            if i.isupper():
                count+=1
        print(count)
    except:break