#include <iostream>
#include <string>
using namespace std;

int main() {
	string str;
	while(cin >> str && str != "0") {
		int len = str.length(), sum = 0;
		for(int i = 0; i < len; i++) sum += str[i] - '0';
		cout << sum << '\n';
	}
	return 0;
}
