import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.array;
import std.math;
import std.range;

void main()
{
    foreach(line; stdin.byLine)
    {
        auto s = line.chomp;
        if(s == "0") return;

        writeln(reduce!"a+b"(0, s.map!"a-'0'"));
    }
}