import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	String str;
	  	String con[] =  new String[1000];
	  	int sumbox[] = new int[1000];
	  	int num = 0;
	  	int sum;
	  	int dig;
		boolean end = false;
		int count = 0;
		
		//初期化
		for(int i = 0; i < 1000 ;i ++) {
	  		con[i] = "";
		}
		
		while( !end  ){
			str = scanner.nextLine();
			count = str.length();		//文字数取得
			sum = 0;
			for(int i = 0; i < 1000 ;i ++) {
		  		sumbox[i] = 0;
			}
			
			//文字列を1文字ずつの数字に
			for(int i = 0; i < count ;i ++) {
		  			con[i] = str.substring(i,i + 1);
		  			sumbox[i] = Short.parseShort(con[i]);
			}
			
			//終了判定したい場所
			if( sumbox[0] == 0 ){
				end = true;
				break;
			}
			//各桁を足す処理
			for(int i = 0; i < count ;i ++) {
		  			sum += sumbox[i];
			}
			//出力
			System.out.println(sum);
		}
		scanner.close();
  }
} import java.util.Scanner; Scanner java.util class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	String str;
	  	String con[] =  new String[1000];
	  	int sumbox[] = new int[1000];
	  	int num = 0;
	  	int sum;
	  	int dig;
		boolean end = false;
		int count = 0;
		
		//初期化
		for(int i = 0; i < 1000 ;i ++) {
	  		con[i] = "";
		}
		
		while( !end  ){
			str = scanner.nextLine();
			count = str.length();		//文字数取得
			sum = 0;
			for(int i = 0; i < 1000 ;i ++) {
		  		sumbox[i] = 0;
			}
			
			//文字列を1文字ずつの数字に
			for(int i = 0; i < count ;i ++) {
		  			con[i] = str.substring(i,i + 1);
		  			sumbox[i] = Short.parseShort(con[i]);
			}
			
			//終了判定したい場所
			if( sumbox[0] == 0 ){
				end = true;
				break;
			}
			//各桁を足す処理
			for(int i = 0; i < count ;i ++) {
		  			sum += sumbox[i];
			}
			//出力
			System.out.println(sum);
		}
		scanner.close();
  }
} Main public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	String str;
	  	String con[] =  new String[1000];
	  	int sumbox[] = new int[1000];
	  	int num = 0;
	  	int sum;
	  	int dig;
		boolean end = false;
		int count = 0;
		
		//初期化
		for(int i = 0; i < 1000 ;i ++) {
	  		con[i] = "";
		}
		
		while( !end  ){
			str = scanner.nextLine();
			count = str.length();		//文字数取得
			sum = 0;
			for(int i = 0; i < 1000 ;i ++) {
		  		sumbox[i] = 0;
			}
			
			//文字列を1文字ずつの数字に
			for(int i = 0; i < count ;i ++) {
		  			con[i] = str.substring(i,i + 1);
		  			sumbox[i] = Short.parseShort(con[i]);
			}
			
			//終了判定したい場所
			if( sumbox[0] == 0 ){
				end = true;
				break;
			}
			//各桁を足す処理
			for(int i = 0; i < count ;i ++) {
		  			sum += sumbox[i];
			}
			//出力
			System.out.println(sum);
		}
		scanner.close();
  } main {
	  	Scanner scanner = new Scanner(System.in);
	  	String str;
	  	String con[] =  new String[1000];
	  	int sumbox[] = new int[1000];
	  	int num = 0;
	  	int sum;
	  	int dig;
		boolean end = false;
		int count = 0;
		
		//初期化
		for(int i = 0; i < 1000 ;i ++) {
	  		con[i] = "";
		}
		
		while( !end  ){
			str = scanner.nextLine();
			count = str.length();		//文字数取得
			sum = 0;
			for(int i = 0; i < 1000 ;i ++) {
		  		sumbox[i] = 0;
			}
			
			//文字列を1文字ずつの数字に
			for(int i = 0; i < count ;i ++) {
		  			con[i] = str.substring(i,i + 1);
		  			sumbox[i] = Short.parseShort(con[i]);
			}
			
			//終了判定したい場所
			if( sumbox[0] == 0 ){
				end = true;
				break;
			}
			//各桁を足す処理
			for(int i = 0; i < count ;i ++) {
		  			sum += sumbox[i];
			}
			//出力
			System.out.println(sum);
		}
		scanner.close();
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String str; str String con[] =  new String[1000]; con new String[1000] 1000 int sumbox[] = new int[1000]; sumbox new int[1000] 1000 int num = 0; num 0 int sum; sum int dig; dig boolean end = false; end false int count = 0; count 0 for(int i = 0; i < 1000 ;i ++) {
	  		con[i] = "";
		} int i = 0; int i = 0; i 0 i < 1000 i 1000 i ++ i ++ i {
	  		con[i] = "";
		} {
	  		con[i] = "";
		} con[i] = "" con[i] con i "" while( !end  ){
			str = scanner.nextLine();
			count = str.length();		//文字数取得
			sum = 0;
			for(int i = 0; i < 1000 ;i ++) {
		  		sumbox[i] = 0;
			}
			
			//文字列を1文字ずつの数字に
			for(int i = 0; i < count ;i ++) {
		  			con[i] = str.substring(i,i + 1);
		  			sumbox[i] = Short.parseShort(con[i]);
			}
			
			//終了判定したい場所
			if( sumbox[0] == 0 ){
				end = true;
				break;
			}
			//各桁を足す処理
			for(int i = 0; i < count ;i ++) {
		  			sum += sumbox[i];
			}
			//出力
			System.out.println(sum);
		} !end end {
			str = scanner.nextLine();
			count = str.length();		//文字数取得
			sum = 0;
			for(int i = 0; i < 1000 ;i ++) {
		  		sumbox[i] = 0;
			}
			
			//文字列を1文字ずつの数字に
			for(int i = 0; i < count ;i ++) {
		  			con[i] = str.substring(i,i + 1);
		  			sumbox[i] = Short.parseShort(con[i]);
			}
			
			//終了判定したい場所
			if( sumbox[0] == 0 ){
				end = true;
				break;
			}
			//各桁を足す処理
			for(int i = 0; i < count ;i ++) {
		  			sum += sumbox[i];
			}
			//出力
			System.out.println(sum);
		} str = scanner.nextLine() str scanner.nextLine() scanner.nextLine scanner count = str.length() count str.length() str.length str sum = 0 sum 0 for(int i = 0; i < 1000 ;i ++) {
		  		sumbox[i] = 0;
			} int i = 0; int i = 0; i 0 i < 1000 i 1000 i ++ i ++ i {
		  		sumbox[i] = 0;
			} {
		  		sumbox[i] = 0;
			} sumbox[i] = 0 sumbox[i] sumbox i 0 for(int i = 0; i < count ;i ++) {
		  			con[i] = str.substring(i,i + 1);
		  			sumbox[i] = Short.parseShort(con[i]);
			} int i = 0; int i = 0; i 0 i < count i count i ++ i ++ i {
		  			con[i] = str.substring(i,i + 1);
		  			sumbox[i] = Short.parseShort(con[i]);
			} {
		  			con[i] = str.substring(i,i + 1);
		  			sumbox[i] = Short.parseShort(con[i]);
			} con[i] = str.substring(i,i + 1) con[i] con i str.substring(i,i + 1) str.substring str i i + 1 i 1 sumbox[i] = Short.parseShort(con[i]) sumbox[i] sumbox i Short.parseShort(con[i]) Short.parseShort Short con[i] con i if( sumbox[0] == 0 ){
				end = true;
				break;
			} sumbox[0] == 0 sumbox[0] sumbox 0 0 {
				end = true;
				break;
			} end = true end true break; for(int i = 0; i < count ;i ++) {
		  			sum += sumbox[i];
			} int i = 0; int i = 0; i 0 i < count i count i ++ i ++ i {
		  			sum += sumbox[i];
			} {
		  			sum += sumbox[i];
			} sum += sumbox[i] sum sumbox[i] sumbox i System.out.println(sum) System.out.println System.out System System.out sum scanner.close() scanner.close scanner String args[] args
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	String str;
	  	String con[] =  new String[1000];
	  	int sumbox[] = new int[1000];
	  	int num = 0;
	  	int sum;
	  	int dig;
		boolean end = false;
		int count = 0;
		
		//初期化
		for(int i = 0; i < 1000 ;i ++) {
	  		con[i] = "";
		}
		
		while( !end  ){
			str = scanner.nextLine();
			count = str.length();		//文字数取得
			sum = 0;
			for(int i = 0; i < 1000 ;i ++) {
		  		sumbox[i] = 0;
			}
			
			//文字列を1文字ずつの数字に
			for(int i = 0; i < count ;i ++) {
		  			con[i] = str.substring(i,i + 1);
		  			sumbox[i] = Short.parseShort(con[i]);
			}
			
			//終了判定したい場所
			if( sumbox[0] == 0 ){
				end = true;
				break;
			}
			//各桁を足す処理
			for(int i = 0; i < count ;i ++) {
		  			sum += sumbox[i];
			}
			//出力
			System.out.println(sum);
		}
		scanner.close();
  }
}
