#include using namespace std; int main() { int n; cin >> n; auto ans = n % 9; if (ans == 0) ans = 9; cout << ans << endl; return 0; }