#include using namespace std; typedef long long ll; ll func(ll x) { ll sum = 0; while(x > 0) { sum += x % 10; x /= 10; } return sum; } int main() { ll ans; cin >> ans; for(int i = 0; i < 100; ++i) { ans = func(ans); } cout << ans << endl; return 0; }