a = input() list_a = list(map(int, a)) b = str(sum(list_a)) list_b = list(map(int, b)) c = str(sum(list_b)) list_c = list(map(int, c)) d = str(sum(list_c)) print(d, end = "\n")