#include using namespace std; int main(){ unsigned long long N,K=9; cin >> N; if(N==0)K=0; N%=9; if(N==0)N+=K; cout << N << endl; }