def answer(x):
    s = str(x)
    
    while len(s) > 1:
        s = str(sum(map(int, list(s))))
        
    return int(s)

print(answer(1235))