#include <iostream>
using namespace std ;
int main() {
	
	
	string a ;	
	cin >> a ;	
	int sum = 0;
	
	while ( a != "0") {
		for (int i=0 ; i <a.size() ; i++){
			sum = sum + a[i] - 48;	
		}	
		cout << sum << endl;
		sum=0;   
		cin >> a;
	}	
}
