#include using namespace std; void solve() { string s; cin >> s; unsigned cnt = 0; while ((s.size() > 1) && (cnt < 100)) { unsigned sum = 0; for (auto c : s) sum += c - '0'; s = to_string(sum); cnt++; } cout << s << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); solve(); getchar(); }