#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; int sum(int nn){ int x=0; while(nn!=0){ x+=nn%10; nn/=10; } return x; } int main() { int n; cin >> n; rep(i,100) n=sum(n); cout << n << endl; }