def main(): a1 = int(input()) a = a1 i = 0 while i < 100: a_str = list(str(a)) a = sum(map(int, a_str)) i += 1 print(a) if __name__ == "__main__": main()