import sys

for line in sys.stdin:
    a = line.split()
    print(len(a[-1]))

伪代码的python就是这么简单,一个函数搞定。