import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
import std.uni;

void main()
{
    while (true)
    {
        auto a = readln;
        if (a == "0\n") break;
        writeln(a.strip.map!(x => x - '0').sum);
    }
}

