import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String n=sc.next();
		while(!n.equals("0")){
			System.out.println(sum(n));
			n=sc.next();
		}
	}
	
	private static int sum(String s){
		int r=0;
		if(s.length()==1){
			r=Integer.parseInt(s);
		}else{
			r=Integer.parseInt(s.substring(0,1))+sum(s.substring(1));
		}
		return r;
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String n=sc.next();
		while(!n.equals("0")){
			System.out.println(sum(n));
			n=sc.next();
		}
	}
	
	private static int sum(String s){
		int r=0;
		if(s.length()==1){
			r=Integer.parseInt(s);
		}else{
			r=Integer.parseInt(s.substring(0,1))+sum(s.substring(1));
		}
		return r;
	}
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String n=sc.next();
		while(!n.equals("0")){
			System.out.println(sum(n));
			n=sc.next();
		}
	} main {
		Scanner sc = new Scanner(System.in);
		String n=sc.next();
		while(!n.equals("0")){
			System.out.println(sum(n));
			n=sc.next();
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String n=sc.next(); n sc.next() sc.next sc while(!n.equals("0")){
			System.out.println(sum(n));
			n=sc.next();
		} !n.equals("0") n.equals("0") n.equals n "0" {
			System.out.println(sum(n));
			n=sc.next();
		} System.out.println(sum(n)) System.out.println System.out System System.out sum(n) sum n n=sc.next() n sc.next() sc.next sc String[] args args private static int sum(String s){
		int r=0;
		if(s.length()==1){
			r=Integer.parseInt(s);
		}else{
			r=Integer.parseInt(s.substring(0,1))+sum(s.substring(1));
		}
		return r;
	} sum {
		int r=0;
		if(s.length()==1){
			r=Integer.parseInt(s);
		}else{
			r=Integer.parseInt(s.substring(0,1))+sum(s.substring(1));
		}
		return r;
	} int r=0; r 0 if(s.length()==1){
			r=Integer.parseInt(s);
		}else{
			r=Integer.parseInt(s.substring(0,1))+sum(s.substring(1));
		} s.length()==1 s.length() s.length s 1 {
			r=Integer.parseInt(s);
		} r=Integer.parseInt(s) r Integer.parseInt(s) Integer.parseInt Integer s {
			r=Integer.parseInt(s.substring(0,1))+sum(s.substring(1));
		} r=Integer.parseInt(s.substring(0,1))+sum(s.substring(1)) r Integer.parseInt(s.substring(0,1))+sum(s.substring(1)) Integer.parseInt(s.substring(0,1)) Integer.parseInt Integer s.substring(0,1) s.substring s 0 1 sum(s.substring(1)) sum s.substring(1) s.substring s 1 return r; r String s s
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String n=sc.next();
		while(!n.equals("0")){
			System.out.println(sum(n));
			n=sc.next();
		}
	}
	
	private static int sum(String s){
		int r=0;
		if(s.length()==1){
			r=Integer.parseInt(s);
		}else{
			r=Integer.parseInt(s.substring(0,1))+sum(s.substring(1));
		}
		return r;
	}
}