#include using namespace std; #define rep(i,N) for(int i=0;i i_i; typedef pair l_l; template using vec = vector; template using vvec = vector>; template< typename T1, typename T2 > ostream &operator<<(ostream &os, const pair< T1, T2 >& p) { os << "{" < inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } const int INF = (ll)1e9; const ll INFLL = (ll)1e18+1; const ll MOD = 1'000'000'007; // const ll MOD = 998244353; const double PI = acos(-1.0); /* const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; const string dir = "DRUL"; */ int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); ll N; cin >> N; vector a(100); a[0] = N; auto calc = [&](ll X){ ll res = 0; while(X > 0){ res += X%10; X /= 10; } return res; }; rep(i,100){ a[i+1] = calc(a[i]); } cout << a[99] << endl; }