import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.StringBuilder;
public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int t = 0;
		do{
			String[] st = sc.readLine().split("");
			int[] x = new int[st.length];
			if(st[0].equals("0"))
				break;
			for(int i = 0;i < st.length;i++){
				x[i] = Integer.parseInt(st[i]);
			}
			for(int n:x){
				t += n;
			}
			sb.append(t).append("\n");
			t = 0;
		}while(true);
		System.out.print(sb);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.lang.StringBuilder; StringBuilder java.lang public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int t = 0;
		do{
			String[] st = sc.readLine().split("");
			int[] x = new int[st.length];
			if(st[0].equals("0"))
				break;
			for(int i = 0;i < st.length;i++){
				x[i] = Integer.parseInt(st[i]);
			}
			for(int n:x){
				t += n;
			}
			sb.append(t).append("\n");
			t = 0;
		}while(true);
		System.out.print(sb);
	}
} Main public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int t = 0;
		do{
			String[] st = sc.readLine().split("");
			int[] x = new int[st.length];
			if(st[0].equals("0"))
				break;
			for(int i = 0;i < st.length;i++){
				x[i] = Integer.parseInt(st[i]);
			}
			for(int n:x){
				t += n;
			}
			sb.append(t).append("\n");
			t = 0;
		}while(true);
		System.out.print(sb);
	} main {
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int t = 0;
		do{
			String[] st = sc.readLine().split("");
			int[] x = new int[st.length];
			if(st[0].equals("0"))
				break;
			for(int i = 0;i < st.length;i++){
				x[i] = Integer.parseInt(st[i]);
			}
			for(int n:x){
				t += n;
			}
			sb.append(t).append("\n");
			t = 0;
		}while(true);
		System.out.print(sb);
	} BufferedReader sc = new BufferedReader(new InputStreamReader(System.in)); sc new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() int t = 0; t 0 do{
			String[] st = sc.readLine().split("");
			int[] x = new int[st.length];
			if(st[0].equals("0"))
				break;
			for(int i = 0;i < st.length;i++){
				x[i] = Integer.parseInt(st[i]);
			}
			for(int n:x){
				t += n;
			}
			sb.append(t).append("\n");
			t = 0;
		}while(true); true {
			String[] st = sc.readLine().split("");
			int[] x = new int[st.length];
			if(st[0].equals("0"))
				break;
			for(int i = 0;i < st.length;i++){
				x[i] = Integer.parseInt(st[i]);
			}
			for(int n:x){
				t += n;
			}
			sb.append(t).append("\n");
			t = 0;
		} String[] st = sc.readLine().split(""); st sc.readLine().split("") sc.readLine().split sc.readLine() sc.readLine sc "" int[] x = new int[st.length]; x new int[st.length] st.length st st.length if(st[0].equals("0"))
				break; st[0].equals("0") st[0].equals st[0] st 0 "0" break; for(int i = 0;i < st.length;i++){
				x[i] = Integer.parseInt(st[i]);
			} int i = 0; int i = 0; i 0 i < st.length i st.length st st.length i++ i++ i {
				x[i] = Integer.parseInt(st[i]);
			} {
				x[i] = Integer.parseInt(st[i]);
			} x[i] = Integer.parseInt(st[i]) x[i] x i Integer.parseInt(st[i]) Integer.parseInt Integer st[i] st i for(int n:x){
				t += n;
			} int n x {
				t += n;
			} {
				t += n;
			} t += n t n sb.append(t).append("\n") sb.append(t).append sb.append(t) sb.append sb t "\n" t = 0 t 0 System.out.print(sb) System.out.print System.out System System.out sb String[] args args public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int t = 0;
		do{
			String[] st = sc.readLine().split("");
			int[] x = new int[st.length];
			if(st[0].equals("0"))
				break;
			for(int i = 0;i < st.length;i++){
				x[i] = Integer.parseInt(st[i]);
			}
			for(int n:x){
				t += n;
			}
			sb.append(t).append("\n");
			t = 0;
		}while(true);
		System.out.print(sb);
	}
} public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int t = 0;
		do{
			String[] st = sc.readLine().split("");
			int[] x = new int[st.length];
			if(st[0].equals("0"))
				break;
			for(int i = 0;i < st.length;i++){
				x[i] = Integer.parseInt(st[i]);
			}
			for(int n:x){
				t += n;
			}
			sb.append(t).append("\n");
			t = 0;
		}while(true);
		System.out.print(sb);
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.StringBuilder;
public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int t = 0;
		do{
			String[] st = sc.readLine().split("");
			int[] x = new int[st.length];
			if(st[0].equals("0"))
				break;
			for(int i = 0;i < st.length;i++){
				x[i] = Integer.parseInt(st[i]);
			}
			for(int n:x){
				t += n;
			}
			sb.append(t).append("\n");
			t = 0;
		}while(true);
		System.out.print(sb);
	}
}