#include int main() { int i, N, M; scanf("%d", &N); for (i = 2; i <= 100; i++) { for (M = 0; N > 0; M += N % 10, N /= 10); N = M; } printf("%d\n", N); fflush(stdout); return 0; }