s=int(input()) while len(str(s))>=2: li=list(str(s)) li_2=[int(i) for i in li] s=sum(li_2) print(s)