#include <bits/stdc++.h>
using namespace std;
int main(){
long long n;
cin >> n;
if(n % 9 == 0) cout << "9";
else cout << n % 9;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKXsKICAgIGxvbmcgbG9uZyBuOwogICAgY2luID4+IG47CiAgICBpZihuICUgOSA9PSAwKSBjb3V0IDw8ICI5IjsKICAgIGVsc2UgY291dCA8PCBuICUgOTsKfQ==