#include using namespace std; using ll = long long; const ll mod = 1000000007; const int INF = 1001001001; int main(){ int n; cin >> n; for(int i = 0; i < 100; i++){ int tmp = 0; while(n){ tmp += n % 10; n /= 10; } n = tmp; //cout << tmp << endl; } cout << n << endl; }