#include using namespace std; #define ll long long #define endl "\n" #define rep(i, a, n) for (int i = a; i < n; ++i) int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int ans = n % 9; if (ans == 0) ans = 9; cout << ans << endl; return 0; }