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

int main(void)
{
	for(string num; cin >> num, num != "0"; ) {
		int sum = 0;

		for(int i = 0; i < num.length(); i++)
			sum += num[i] - '0';
	
		cout << sum << endl;
	}

	return 0;
}