#include #define rep(i,N) for(ll (i)=0;(i)<(N);(i)++) #define chmax(x,y) x=max(x,y) #define chmin(x,y) x=min(x,y) using namespace std; typedef long long ll; typedef pair P; const int mod = 1000000007; const int INF = 1001001001; int f(int x) { int res = 0; while (x > 0) { res += x % 10; x /= 10; } return res; } int main() { int n; cin >> n; int ans = n; rep(i, 100) { ans = f(ans); } cout << ans << endl; }