#include using namespace std; int main() { int n; cin >> n; int x = n; for (int i = 1; i < 100; i++) { int t = x, sum = 0; while (t > 0) { sum += t%10; t /= 10; } x = sum; } cout << x << endl; return 0; }