import java.util.*;

public class Main {
	private static Scanner sc=new Scanner(System.in);;

	public static void main(String args[]) {
		//System.out.println((int)'1');
		while(sc.hasNextLine()){
			char a[]=sc.nextLine().toCharArray();
			if(a[0]==48)break;
			int ans=0;
			for(int i=0;i<a.length;i++){

				ans+=a[i]-48;
			}
			System.out.println(ans);
		}
	}
} import java.util.*; util.* java public class Main {
	private static Scanner sc=new Scanner(System.in);;

	public static void main(String args[]) {
		//System.out.println((int)'1');
		while(sc.hasNextLine()){
			char a[]=sc.nextLine().toCharArray();
			if(a[0]==48)break;
			int ans=0;
			for(int i=0;i<a.length;i++){

				ans+=a[i]-48;
			}
			System.out.println(ans);
		}
	}
} Main private static Scanner sc=new Scanner(System.in); sc new Scanner(System.in) public static void main(String args[]) {
		//System.out.println((int)'1');
		while(sc.hasNextLine()){
			char a[]=sc.nextLine().toCharArray();
			if(a[0]==48)break;
			int ans=0;
			for(int i=0;i<a.length;i++){

				ans+=a[i]-48;
			}
			System.out.println(ans);
		}
	} main {
		//System.out.println((int)'1');
		while(sc.hasNextLine()){
			char a[]=sc.nextLine().toCharArray();
			if(a[0]==48)break;
			int ans=0;
			for(int i=0;i<a.length;i++){

				ans+=a[i]-48;
			}
			System.out.println(ans);
		}
	} while(sc.hasNextLine()){
			char a[]=sc.nextLine().toCharArray();
			if(a[0]==48)break;
			int ans=0;
			for(int i=0;i<a.length;i++){

				ans+=a[i]-48;
			}
			System.out.println(ans);
		} sc.hasNextLine() sc.hasNextLine sc {
			char a[]=sc.nextLine().toCharArray();
			if(a[0]==48)break;
			int ans=0;
			for(int i=0;i<a.length;i++){

				ans+=a[i]-48;
			}
			System.out.println(ans);
		} char a[]=sc.nextLine().toCharArray(); a sc.nextLine().toCharArray() sc.nextLine().toCharArray sc.nextLine() sc.nextLine sc if(a[0]==48)break; a[0]==48 a[0] a 0 48 break; int ans=0; ans 0 for(int i=0;i<a.length;i++){

				ans+=a[i]-48;
			} int i=0; int i=0; i 0 i<a.length i a.length a a.length i++ i++ i {

				ans+=a[i]-48;
			} {

				ans+=a[i]-48;
			} ans+=a[i]-48 ans a[i]-48 a[i] a i 48 System.out.println(ans) System.out.println System.out System System.out ans String args[] args public class Main {
	private static Scanner sc=new Scanner(System.in);;

	public static void main(String args[]) {
		//System.out.println((int)'1');
		while(sc.hasNextLine()){
			char a[]=sc.nextLine().toCharArray();
			if(a[0]==48)break;
			int ans=0;
			for(int i=0;i<a.length;i++){

				ans+=a[i]-48;
			}
			System.out.println(ans);
		}
	}
} public class Main {
	private static Scanner sc=new Scanner(System.in);;

	public static void main(String args[]) {
		//System.out.println((int)'1');
		while(sc.hasNextLine()){
			char a[]=sc.nextLine().toCharArray();
			if(a[0]==48)break;
			int ans=0;
			for(int i=0;i<a.length;i++){

				ans+=a[i]-48;
			}
			System.out.println(ans);
		}
	}
} Main
import java.util.*;

public class Main {
	private static Scanner sc=new Scanner(System.in);;

	public static void main(String args[]) {
		//System.out.println((int)'1');
		while(sc.hasNextLine()){
			char a[]=sc.nextLine().toCharArray();
			if(a[0]==48)break;
			int ans=0;
			for(int i=0;i<a.length;i++){

				ans+=a[i]-48;
			}
			System.out.println(ans);
		}
	}
}