#include using namespace std; typedef int64_t Int; #define all(x) (x).begin(), (x).end() const double EPS = 1e-10; const Int INF = 1e18; const int inf = 1e9; const Int mod = 1e9+7; bool print_space_enable = false; void print() { cout << '\n'; print_space_enable = false; } template void print(Head&& head, Tail&&... tail) { if (print_space_enable) cout << " "; cout << fixed << setprecision(15) << head; print_space_enable = true; print(std::forward(tail)...); } template void print(vector v) { for (size_t i = 0; i < v.size(); i++) { if (i > 0) std::cout << " "; std::cout << v[i]; } std::cout << std::endl; } Int f(Int x) { Int ret = 0; while (x > 0) { ret += x % 10; x /= 10; } return ret; } int main() { Int n; cin >> n; for (Int i = 2; i <= 100; i++) { n = f(n); } print(n); return 0; }