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

void main() {
	auto input = getStdin!(int[]);
	
	foreach (i; input) {
		if (i == 0) break;
		char[] na = i.abs.to!(string).dup;
		int[] res = [];
		foreach (n; na) res ~= n.to!(int) - 48;
		res.reduce!"a + b".writeln;
	}
}

T getStdin(T)() {
    string[] cmd;
    string line;
    while ((line = chomp(stdin.readln())) != "") cmd ~= line;
    return to!(T)(cmd);
}