#include using namespace std; using namespace chrono; #if __has_include() #include using namespace atcoder; #endif int main() { int64_t n; cin >> n; auto f = [](int64_t x) -> int64_t { int64_t ret = 0; for (; x; x /= 10) { ret += x % 10; } return ret; }; for (int64_t i = 0; i < 99; i++) { n = f(n); } cout << n << endl; return 0; }