N = int(input()) ans = [0,N] for i in range(2,101): k = list(str(ans[-1])) ii = 0 for s in k: ii += int(s) ans.append(ii) print(ans[100])