a = input() array = list(map(int, a)) b = str(sum(array)) array = list(map(int, b)) c = str(sum(array)) d = list(map(int, c))[0] print(d)