#include using namespace std; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl template ostream& operator << (ostream &s, pair P) { return s << '<' << P.first << ", " << P.second << '>'; } template ostream& operator << (ostream &s, vector P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template ostream& operator << (ostream &s, vector > P) { for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; } template ostream& operator << (ostream &s, set P) { for(auto it : P) { s << "<" << it << "> "; } return s << endl; } template ostream& operator << (ostream &s, map P) { for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; } int main() { string N; cin >> N; int res = 0; for (auto c : N) res += c - '0'; cout << res % 9 << endl; }