import java.io.BufferedReader;
import java.io.InputStreamReader;

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

			}catch (Exception e) {
				System.err.println(e);
			}
		}
	}

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

			}catch (Exception e) {
				System.err.println(e);
			}
		}
	}

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

			}catch (Exception e) {
				System.err.println(e);
			}
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int sum;
		String str[];
		while(true){
			sum=0;
			try{
				str=br.readLine().split("");
				if(str[0].equals("0")){
					break;
				}
				for(int i = 0 ; i < str.length ; i++){
					sum += Integer.parseInt(str[i]);
				}
				System.out.println(sum);

			}catch (Exception e) {
				System.err.println(e);
			}
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int sum; sum String str[]; str while(true){
			sum=0;
			try{
				str=br.readLine().split("");
				if(str[0].equals("0")){
					break;
				}
				for(int i = 0 ; i < str.length ; i++){
					sum += Integer.parseInt(str[i]);
				}
				System.out.println(sum);

			}catch (Exception e) {
				System.err.println(e);
			}
		} true {
			sum=0;
			try{
				str=br.readLine().split("");
				if(str[0].equals("0")){
					break;
				}
				for(int i = 0 ; i < str.length ; i++){
					sum += Integer.parseInt(str[i]);
				}
				System.out.println(sum);

			}catch (Exception e) {
				System.err.println(e);
			}
		} sum=0 sum 0 try{
				str=br.readLine().split("");
				if(str[0].equals("0")){
					break;
				}
				for(int i = 0 ; i < str.length ; i++){
					sum += Integer.parseInt(str[i]);
				}
				System.out.println(sum);

			}catch (Exception e) {
				System.err.println(e);
			} catch (Exception e) {
				System.err.println(e);
			} Exception e {
				System.err.println(e);
			} System.err.println(e) System.err.println System.err System System.err e {
				str=br.readLine().split("");
				if(str[0].equals("0")){
					break;
				}
				for(int i = 0 ; i < str.length ; i++){
					sum += Integer.parseInt(str[i]);
				}
				System.out.println(sum);

			} str=br.readLine().split("") str br.readLine().split("") br.readLine().split br.readLine() br.readLine br "" if(str[0].equals("0")){
					break;
				} str[0].equals("0") str[0].equals str[0] str 0 "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){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int sum;
		String str[];
		while(true){
			sum=0;
			try{
				str=br.readLine().split("");
				if(str[0].equals("0")){
					break;
				}
				for(int i = 0 ; i < str.length ; i++){
					sum += Integer.parseInt(str[i]);
				}
				System.out.println(sum);

			}catch (Exception e) {
				System.err.println(e);
			}
		}
	}

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

			}catch (Exception e) {
				System.err.println(e);
			}
		}
	}

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

			}catch (Exception e) {
				System.err.println(e);
			}
		}
	}

}