num=int(input())
while(num>9):
    sum=0
    for i in range(len(str(num))):
        sum=sum+int(str(num)[i])
    num=sum
print(num)
a5ec8c579aa0817a22c203809d4e12df0002f48d
<mask token>

<mask token>
while num > 9:
    sum = 0
    for i in range(len(str(num))):
        sum = sum + int(str(num)[i])
    num = sum
print(num)

num = int(input())
while num > 9:
    sum = 0
    for i in range(len(str(num))):
        sum = sum + int(str(num)[i])
    num = sum
print(num)

num=int(input())
while(num>9):
    sum=0
    for i in range(len(str(num))):
        sum=sum+int(str(num)[i])
    num=sum
print(num)