// #define _GLIBCXX_DEBUG #include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int digitSum(int n) { int ret = 0; while (n != 0) ret += n % 10, n /= 10; return ret; } int main() { // Input int N; cin >> N; // Calculation int a[101]; a[1] = N; for (int i = 2; i <= 100; ++i) a[i] = digitSum(a[i - 1]); // Output cout << a[100] << endl; }