#include using namespace std; int main(){ int N; cin >> N; for(int i = 0; i < 100; i++){ int sum = 0; while(N > 0){ sum += N % 10; N /= 10; } N = sum; } cout << N << endl; }