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

int main(){
	string a;
	while(cin >> a){
		if(a.compare("0") == 0)
			break;
		int sum = 0;
		for(int i = 0; i < a.length(); i++){
			sum += a[i] - 48;
		}
		cout << sum << endl;
	}
}
