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