import std.stdio, std.string, std.conv;

void main() {
    while (true) {
        string str = readln.chomp;
        if (str == "0") break;
        int sum = 0;
        foreach (x; str) {
            sum += x - '0';
        }
        sum.writeln;
    }
}
