import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc = new Scanner(System.in);
		while(true){
			String num = sc.nextLine();
			if(num.equals("0"))break;
			int ans=0;
			for(int i=0;i<num.length();i++){
				ans+=Integer.parseInt(""+num.charAt(i));
			}
			System.out.println(ans);
		}
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc = new Scanner(System.in);
		while(true){
			String num = sc.nextLine();
			if(num.equals("0"))break;
			int ans=0;
			for(int i=0;i<num.length();i++){
				ans+=Integer.parseInt(""+num.charAt(i));
			}
			System.out.println(ans);
		}
	}

} Main public static Scanner sc; sc public static void main(String[] args){
		sc = new Scanner(System.in);
		while(true){
			String num = sc.nextLine();
			if(num.equals("0"))break;
			int ans=0;
			for(int i=0;i<num.length();i++){
				ans+=Integer.parseInt(""+num.charAt(i));
			}
			System.out.println(ans);
		}
	} main {
		sc = new Scanner(System.in);
		while(true){
			String num = sc.nextLine();
			if(num.equals("0"))break;
			int ans=0;
			for(int i=0;i<num.length();i++){
				ans+=Integer.parseInt(""+num.charAt(i));
			}
			System.out.println(ans);
		}
	} sc = new Scanner(System.in) sc new Scanner(System.in) while(true){
			String num = sc.nextLine();
			if(num.equals("0"))break;
			int ans=0;
			for(int i=0;i<num.length();i++){
				ans+=Integer.parseInt(""+num.charAt(i));
			}
			System.out.println(ans);
		} true {
			String num = sc.nextLine();
			if(num.equals("0"))break;
			int ans=0;
			for(int i=0;i<num.length();i++){
				ans+=Integer.parseInt(""+num.charAt(i));
			}
			System.out.println(ans);
		} String num = sc.nextLine(); num sc.nextLine() sc.nextLine sc if(num.equals("0"))break; num.equals("0") num.equals num "0" break; int ans=0; ans 0 for(int i=0;i<num.length();i++){
				ans+=Integer.parseInt(""+num.charAt(i));
			} int i=0; int i=0; i 0 i<num.length() i num.length() num.length num i++ i++ i {
				ans+=Integer.parseInt(""+num.charAt(i));
			} {
				ans+=Integer.parseInt(""+num.charAt(i));
			} ans+=Integer.parseInt(""+num.charAt(i)) ans Integer.parseInt(""+num.charAt(i)) Integer.parseInt Integer ""+num.charAt(i) "" num.charAt(i) num.charAt num i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc = new Scanner(System.in);
		while(true){
			String num = sc.nextLine();
			if(num.equals("0"))break;
			int ans=0;
			for(int i=0;i<num.length();i++){
				ans+=Integer.parseInt(""+num.charAt(i));
			}
			System.out.println(ans);
		}
	}

} public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc = new Scanner(System.in);
		while(true){
			String num = sc.nextLine();
			if(num.equals("0"))break;
			int ans=0;
			for(int i=0;i<num.length();i++){
				ans+=Integer.parseInt(""+num.charAt(i));
			}
			System.out.println(ans);
		}
	}

} Main
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc = new Scanner(System.in);
		while(true){
			String num = sc.nextLine();
			if(num.equals("0"))break;
			int ans=0;
			for(int i=0;i<num.length();i++){
				ans+=Integer.parseInt(""+num.charAt(i));
			}
			System.out.println(ans);
		}
	}

}