#include<iostream> #include<string> using namespace std; int char2int(char c) { return c - '0'; } char int2char(int d) { return d + '0'; } int main() { string number_str; while (cin >> number_str) { while (number_str.size() != 1) { int sum = 0; for (int i = 0; i < number_str.size(); i++) { sum = sum + char2int(number_str[i]); } number_str = to_string(sum); } cout << number_str << endl; } }