#include <iostream>
#include <fstream>
#include <math.h>
#include <string>

using namespace std;


int main() 
{
	ifstream fin("input.txt");
	ofstream fout("output.txt");
	string s;
        fin >> s;
        int d = 0;
        for (int i=0; i<s.length(); i++)
        {
           d+=(s[i]-'0'); d%=9;
        }
        if (d==0) d=9; 
        fout << d; 
        fout.close();
        return 0;
}