#include using namespace std; int64_t f(int64_t n) { int64_t ret = 0; while (n > 0) { ret += n % 10; n /= 10; } return ret; } int main() { int64_t N; cin >> N; for (int i = 0; i < 100; i++) { N = f(N); } cout << N << endl; }