#include <bits/stdc++.h>

#define int long long

using namespace std;

signed main(){
    int a;
    cin >> a;
    int x = 0;
    while(a){
        x = (x+a%10)%9;
        a/=10;
    }
    if(x==0) x += 9;
    cout << x << "\n";
}