import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
		
            String str;
            int sum=0;
			while( true ) {
				str = kb.readLine();
				if( "0".equals( str ) ) { break; }
				
				char[] strArr = str.toCharArray();
				sum=0;
           		for( int i=0; i<strArr.length; i++ ) {
           			sum += ( strArr[i] - '0' );
           		}
				System.out.println( sum );
			}
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
} import java.io.*; io.* java class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
		
            String str;
            int sum=0;
			while( true ) {
				str = kb.readLine();
				if( "0".equals( str ) ) { break; }
				
				char[] strArr = str.toCharArray();
				sum=0;
           		for( int i=0; i<strArr.length; i++ ) {
           			sum += ( strArr[i] - '0' );
           		}
				System.out.println( sum );
			}
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
} Main public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
		
            String str;
            int sum=0;
			while( true ) {
				str = kb.readLine();
				if( "0".equals( str ) ) { break; }
				
				char[] strArr = str.toCharArray();
				sum=0;
           		for( int i=0; i<strArr.length; i++ ) {
           			sum += ( strArr[i] - '0' );
           		}
				System.out.println( sum );
			}
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	} main {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
		
            String str;
            int sum=0;
			while( true ) {
				str = kb.readLine();
				if( "0".equals( str ) ) { break; }
				
				char[] strArr = str.toCharArray();
				sum=0;
           		for( int i=0; i<strArr.length; i++ ) {
           			sum += ( strArr[i] - '0' );
           		}
				System.out.println( sum );
			}
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	} BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) ); kb new BufferedReader( new InputStreamReader( System.in ) ) try {
		
            String str;
            int sum=0;
			while( true ) {
				str = kb.readLine();
				if( "0".equals( str ) ) { break; }
				
				char[] strArr = str.toCharArray();
				sum=0;
           		for( int i=0; i<strArr.length; i++ ) {
           			sum += ( strArr[i] - '0' );
           		}
				System.out.println( sum );
			}
			
		} catch( IOException e ) {
			System.err.println( e );
		} catch( IOException e ) {
			System.err.println( e );
		} IOException e {
			System.err.println( e );
		} System.err.println( e ) System.err.println System.err System System.err e {
		
            String str;
            int sum=0;
			while( true ) {
				str = kb.readLine();
				if( "0".equals( str ) ) { break; }
				
				char[] strArr = str.toCharArray();
				sum=0;
           		for( int i=0; i<strArr.length; i++ ) {
           			sum += ( strArr[i] - '0' );
           		}
				System.out.println( sum );
			}
			
		} String str; str int sum=0; sum 0 while( true ) {
				str = kb.readLine();
				if( "0".equals( str ) ) { break; }
				
				char[] strArr = str.toCharArray();
				sum=0;
           		for( int i=0; i<strArr.length; i++ ) {
           			sum += ( strArr[i] - '0' );
           		}
				System.out.println( sum );
			} true {
				str = kb.readLine();
				if( "0".equals( str ) ) { break; }
				
				char[] strArr = str.toCharArray();
				sum=0;
           		for( int i=0; i<strArr.length; i++ ) {
           			sum += ( strArr[i] - '0' );
           		}
				System.out.println( sum );
			} str = kb.readLine() str kb.readLine() kb.readLine kb if( "0".equals( str ) ) { break; } "0".equals( str ) "0".equals "0" str { break; } break; char[] strArr = str.toCharArray(); strArr str.toCharArray() str.toCharArray str sum=0 sum 0 for( int i=0; i<strArr.length; i++ ) {
           			sum += ( strArr[i] - '0' );
           		} int i=0; int i=0; i 0 i<strArr.length i strArr.length strArr strArr.length i++ i++ i {
           			sum += ( strArr[i] - '0' );
           		} {
           			sum += ( strArr[i] - '0' );
           		} sum += ( strArr[i] - '0' ) sum ( strArr[i] - '0' ) strArr[i] strArr i '0' 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) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
		
            String str;
            int sum=0;
			while( true ) {
				str = kb.readLine();
				if( "0".equals( str ) ) { break; }
				
				char[] strArr = str.toCharArray();
				sum=0;
           		for( int i=0; i<strArr.length; i++ ) {
           			sum += ( strArr[i] - '0' );
           		}
				System.out.println( sum );
			}
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}