import java.util.Arrays;
import java.util.Scanner;

public class Main{

	static Scanner s=new Scanner(System.in);

	public static void main(String __[]){
		while(true) {
			input();
			if(in.charAt(0)=='0') return;
			solve();
		}
	}

	static String in;
	private static void input(){
		in=s.next();
	}

	private static void solve(){
		int[] x=new int[in.length()];
		for(int i=0;i<in.length();i++)
			x[i]=in.charAt(i)-'0';
		System.out.println(Arrays.stream(x).parallel().sum());
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main{

	static Scanner s=new Scanner(System.in);

	public static void main(String __[]){
		while(true) {
			input();
			if(in.charAt(0)=='0') return;
			solve();
		}
	}

	static String in;
	private static void input(){
		in=s.next();
	}

	private static void solve(){
		int[] x=new int[in.length()];
		for(int i=0;i<in.length();i++)
			x[i]=in.charAt(i)-'0';
		System.out.println(Arrays.stream(x).parallel().sum());
	}
} Main static Scanner s=new Scanner(System.in); s new Scanner(System.in) static String in; in public static void main(String __[]){
		while(true) {
			input();
			if(in.charAt(0)=='0') return;
			solve();
		}
	} main {
		while(true) {
			input();
			if(in.charAt(0)=='0') return;
			solve();
		}
	} while(true) {
			input();
			if(in.charAt(0)=='0') return;
			solve();
		} true {
			input();
			if(in.charAt(0)=='0') return;
			solve();
		} input() input if(in.charAt(0)=='0') return; in.charAt(0)=='0' in.charAt(0) in.charAt in 0 '0' return; solve() solve String __[] __ private static void input(){
		in=s.next();
	} input {
		in=s.next();
	} in=s.next() in s.next() s.next s private static void solve(){
		int[] x=new int[in.length()];
		for(int i=0;i<in.length();i++)
			x[i]=in.charAt(i)-'0';
		System.out.println(Arrays.stream(x).parallel().sum());
	} solve {
		int[] x=new int[in.length()];
		for(int i=0;i<in.length();i++)
			x[i]=in.charAt(i)-'0';
		System.out.println(Arrays.stream(x).parallel().sum());
	} int[] x=new int[in.length()]; x new int[in.length()] in.length() in.length in for(int i=0;i<in.length();i++)
			x[i]=in.charAt(i)-'0'; int i=0; int i=0; i 0 i<in.length() i in.length() in.length in i++ i++ i x[i]=in.charAt(i)-'0'; x[i]=in.charAt(i)-'0' x[i] x i in.charAt(i)-'0' in.charAt(i) in.charAt in i '0' System.out.println(Arrays.stream(x).parallel().sum()) System.out.println System.out System System.out Arrays.stream(x).parallel().sum() Arrays.stream(x).parallel().sum Arrays.stream(x).parallel() Arrays.stream(x).parallel Arrays.stream(x) Arrays.stream Arrays x public class Main{

	static Scanner s=new Scanner(System.in);

	public static void main(String __[]){
		while(true) {
			input();
			if(in.charAt(0)=='0') return;
			solve();
		}
	}

	static String in;
	private static void input(){
		in=s.next();
	}

	private static void solve(){
		int[] x=new int[in.length()];
		for(int i=0;i<in.length();i++)
			x[i]=in.charAt(i)-'0';
		System.out.println(Arrays.stream(x).parallel().sum());
	}
} public class Main{

	static Scanner s=new Scanner(System.in);

	public static void main(String __[]){
		while(true) {
			input();
			if(in.charAt(0)=='0') return;
			solve();
		}
	}

	static String in;
	private static void input(){
		in=s.next();
	}

	private static void solve(){
		int[] x=new int[in.length()];
		for(int i=0;i<in.length();i++)
			x[i]=in.charAt(i)-'0';
		System.out.println(Arrays.stream(x).parallel().sum());
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	static Scanner s=new Scanner(System.in);

	public static void main(String __[]){
		while(true) {
			input();
			if(in.charAt(0)=='0') return;
			solve();
		}
	}

	static String in;
	private static void input(){
		in=s.next();
	}

	private static void solve(){
		int[] x=new int[in.length()];
		for(int i=0;i<in.length();i++)
			x[i]=in.charAt(i)-'0';
		System.out.println(Arrays.stream(x).parallel().sum());
	}
}