#include using namespace std; /* * @title NBase */ class NBase{ public: inline static vector translate(long long X,long long N) { assert(abs(N)>1); vector res; while(1) { long long b = (X%abs(N)+abs(N)) % abs(N); res.push_back(b); (X -= b) /= N; if(X==0) break; } return res; } //Digit Sum inline static constexpr long long digit_sum(long long N, long long K) { long long sum = 0; for (; N > 0; N /= K) sum += N % K; return sum; } }; int main() { int N; cin >> N; assert(1 <= N && N <= 1'000'000'000); for(int i = 2; i <= 100; ++i) { N = NBase::digit_sum(N,10); } cout << N << endl; return 0; }