import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			String[] str = line.split("");
			int sum = 0;
			if ("0".equals(str[0])){break;}
			for (int i = 0 ; i < str.length ; i++ ) {
				sum += Integer.parseInt(str[i]);
			}
		System.out.println(sum);
		}
	}
} import java.io.*; io.* java import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			String[] str = line.split("");
			int sum = 0;
			if ("0".equals(str[0])){break;}
			for (int i = 0 ; i < str.length ; i++ ) {
				sum += Integer.parseInt(str[i]);
			}
		System.out.println(sum);
		}
	}
} Main public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			String[] str = line.split("");
			int sum = 0;
			if ("0".equals(str[0])){break;}
			for (int i = 0 ; i < str.length ; i++ ) {
				sum += Integer.parseInt(str[i]);
			}
		System.out.println(sum);
		}
	} main { 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			String[] str = line.split("");
			int sum = 0;
			if ("0".equals(str[0])){break;}
			for (int i = 0 ; i < str.length ; i++ ) {
				sum += Integer.parseInt(str[i]);
			}
		System.out.println(sum);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			String line = br.readLine();
			String[] str = line.split("");
			int sum = 0;
			if ("0".equals(str[0])){break;}
			for (int i = 0 ; i < str.length ; i++ ) {
				sum += Integer.parseInt(str[i]);
			}
		System.out.println(sum);
		} true {
			String line = br.readLine();
			String[] str = line.split("");
			int sum = 0;
			if ("0".equals(str[0])){break;}
			for (int i = 0 ; i < str.length ; i++ ) {
				sum += Integer.parseInt(str[i]);
			}
		System.out.println(sum);
		} String line = br.readLine(); line br.readLine() br.readLine br String[] str = line.split(""); str line.split("") line.split line "" int sum = 0; sum 0 if ("0".equals(str[0])){break;} "0".equals(str[0]) "0".equals "0" str[0] str 0 {break;} break; for (int i = 0 ; i < str.length ; i++ ) {
				sum += Integer.parseInt(str[i]);
			} int i = 0 ; int i = 0 ; i 0 i < str.length i str.length str str.length i++ i++ i {
				sum += Integer.parseInt(str[i]);
			} {
				sum += Integer.parseInt(str[i]);
			} sum += Integer.parseInt(str[i]) sum Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			String[] str = line.split("");
			int sum = 0;
			if ("0".equals(str[0])){break;}
			for (int i = 0 ; i < str.length ; i++ ) {
				sum += Integer.parseInt(str[i]);
			}
		System.out.println(sum);
		}
	}
} public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			String[] str = line.split("");
			int sum = 0;
			if ("0".equals(str[0])){break;}
			for (int i = 0 ; i < str.length ; i++ ) {
				sum += Integer.parseInt(str[i]);
			}
		System.out.println(sum);
		}
	}
} Main
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			String[] str = line.split("");
			int sum = 0;
			if ("0".equals(str[0])){break;}
			for (int i = 0 ; i < str.length ; i++ ) {
				sum += Integer.parseInt(str[i]);
			}
		System.out.println(sum);
		}
	}
}