/** * author: boutarou * created: 14.08.2020 21:18:27 **/ #include using namespace std; #define rep(i,n) for(int i = 0; i < int(n); i++) using ll = long long; using P = pair; long long digit(long long x) { long long cnt = 0; while (x > 0) { cnt += x % 10; x /= 10; } return cnt; } int main() { ll n; cin >> n; rep(i,99) { n = digit(n); } cout << n << endl; return 0; }