#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	while(1){
		int ss=0;
		cin>>s;
		for(int i=0;i<s.size();i++){
			ss+=(s[i]-'0');
			}
		if(ss==0)break;
		cout<<ss<<endl;;
	}
}

