import java.io.*;

class Main{
	public static void main(String[] args){
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			int i,sum;
			while(true){
				str = br.readLine();
				if(str.equals("0")) break;
				for( i=0, sum=0; i<str.length(); i++ ){
					sum += Integer.parseInt(""+str.charAt(i));
				}
				System.out.println(sum);
			}
		} catch(IOException e){
			System.out.println("Exception :" + e);
		}
	}
} import java.io.*; io.* java class Main{
	public static void main(String[] args){
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			int i,sum;
			while(true){
				str = br.readLine();
				if(str.equals("0")) break;
				for( i=0, sum=0; i<str.length(); i++ ){
					sum += Integer.parseInt(""+str.charAt(i));
				}
				System.out.println(sum);
			}
		} catch(IOException e){
			System.out.println("Exception :" + e);
		}
	}
} Main public static void main(String[] args){
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			int i,sum;
			while(true){
				str = br.readLine();
				if(str.equals("0")) break;
				for( i=0, sum=0; i<str.length(); i++ ){
					sum += Integer.parseInt(""+str.charAt(i));
				}
				System.out.println(sum);
			}
		} catch(IOException e){
			System.out.println("Exception :" + e);
		}
	} main {
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			int i,sum;
			while(true){
				str = br.readLine();
				if(str.equals("0")) break;
				for( i=0, sum=0; i<str.length(); i++ ){
					sum += Integer.parseInt(""+str.charAt(i));
				}
				System.out.println(sum);
			}
		} catch(IOException e){
			System.out.println("Exception :" + e);
		}
	} try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			int i,sum;
			while(true){
				str = br.readLine();
				if(str.equals("0")) break;
				for( i=0, sum=0; i<str.length(); i++ ){
					sum += Integer.parseInt(""+str.charAt(i));
				}
				System.out.println(sum);
			}
		} catch(IOException e){
			System.out.println("Exception :" + e);
		} catch(IOException e){
			System.out.println("Exception :" + e);
		} IOException e {
			System.out.println("Exception :" + e);
		} System.out.println("Exception :" + e) System.out.println System.out System System.out "Exception :" + e "Exception :" e {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			int i,sum;
			while(true){
				str = br.readLine();
				if(str.equals("0")) break;
				for( i=0, sum=0; i<str.length(); i++ ){
					sum += Integer.parseInt(""+str.charAt(i));
				}
				System.out.println(sum);
			}
		} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str int i i sum; sum while(true){
				str = br.readLine();
				if(str.equals("0")) break;
				for( i=0, sum=0; i<str.length(); i++ ){
					sum += Integer.parseInt(""+str.charAt(i));
				}
				System.out.println(sum);
			} true {
				str = br.readLine();
				if(str.equals("0")) break;
				for( i=0, sum=0; i<str.length(); i++ ){
					sum += Integer.parseInt(""+str.charAt(i));
				}
				System.out.println(sum);
			} str = br.readLine() str br.readLine() br.readLine br if(str.equals("0")) break; str.equals("0") str.equals str "0" break; for( i=0, sum=0; i<str.length(); i++ ){
					sum += Integer.parseInt(""+str.charAt(i));
				} i=0, sum=0; i=0 i 0 sum=0 sum 0 i<str.length() i str.length() str.length str i++ i++ i {
					sum += Integer.parseInt(""+str.charAt(i));
				} {
					sum += Integer.parseInt(""+str.charAt(i));
				} sum += Integer.parseInt(""+str.charAt(i)) sum Integer.parseInt(""+str.charAt(i)) Integer.parseInt Integer ""+str.charAt(i) "" str.charAt(i) str.charAt str i System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.io.*;

class Main{
	public static void main(String[] args){
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			int i,sum;
			while(true){
				str = br.readLine();
				if(str.equals("0")) break;
				for( i=0, sum=0; i<str.length(); i++ ){
					sum += Integer.parseInt(""+str.charAt(i));
				}
				System.out.println(sum);
			}
		} catch(IOException e){
			System.out.println("Exception :" + e);
		}
	}
}