
import java.io.*;
public class Main {
	private static int sum;
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		while(str.equals("0")!=true){
			sum=0;
			for(int i=0;i<str.length();i++){
				String a=str.substring(i, i+1);
				int n=Integer.parseInt(a);
				sum+=n;
			}
			System.out.println(sum);
			str=br.readLine();
		}
	}
} import java.io.*; io.* java public class Main {
	private static int sum;
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		while(str.equals("0")!=true){
			sum=0;
			for(int i=0;i<str.length();i++){
				String a=str.substring(i, i+1);
				int n=Integer.parseInt(a);
				sum+=n;
			}
			System.out.println(sum);
			str=br.readLine();
		}
	}
} Main private static int sum; sum public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		while(str.equals("0")!=true){
			sum=0;
			for(int i=0;i<str.length();i++){
				String a=str.substring(i, i+1);
				int n=Integer.parseInt(a);
				sum+=n;
			}
			System.out.println(sum);
			str=br.readLine();
		}
	} main {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		while(str.equals("0")!=true){
			sum=0;
			for(int i=0;i<str.length();i++){
				String a=str.substring(i, i+1);
				int n=Integer.parseInt(a);
				sum+=n;
			}
			System.out.println(sum);
			str=br.readLine();
		}
	} BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str=br.readLine(); str br.readLine() br.readLine br while(str.equals("0")!=true){
			sum=0;
			for(int i=0;i<str.length();i++){
				String a=str.substring(i, i+1);
				int n=Integer.parseInt(a);
				sum+=n;
			}
			System.out.println(sum);
			str=br.readLine();
		} str.equals("0")!=true str.equals("0") str.equals str "0" true {
			sum=0;
			for(int i=0;i<str.length();i++){
				String a=str.substring(i, i+1);
				int n=Integer.parseInt(a);
				sum+=n;
			}
			System.out.println(sum);
			str=br.readLine();
		} sum=0 sum 0 for(int i=0;i<str.length();i++){
				String a=str.substring(i, i+1);
				int n=Integer.parseInt(a);
				sum+=n;
			} int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
				String a=str.substring(i, i+1);
				int n=Integer.parseInt(a);
				sum+=n;
			} {
				String a=str.substring(i, i+1);
				int n=Integer.parseInt(a);
				sum+=n;
			} String a=str.substring(i, i+1); a str.substring(i, i+1) str.substring str i i+1 i 1 int n=Integer.parseInt(a); n Integer.parseInt(a) Integer.parseInt Integer a sum+=n sum n System.out.println(sum) System.out.println System.out System System.out sum str=br.readLine() str br.readLine() br.readLine br String[] args args public class Main {
	private static int sum;
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		while(str.equals("0")!=true){
			sum=0;
			for(int i=0;i<str.length();i++){
				String a=str.substring(i, i+1);
				int n=Integer.parseInt(a);
				sum+=n;
			}
			System.out.println(sum);
			str=br.readLine();
		}
	}
} public class Main {
	private static int sum;
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		while(str.equals("0")!=true){
			sum=0;
			for(int i=0;i<str.length();i++){
				String a=str.substring(i, i+1);
				int n=Integer.parseInt(a);
				sum+=n;
			}
			System.out.println(sum);
			str=br.readLine();
		}
	}
} Main

import java.io.*;
public class Main {
	private static int sum;
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		while(str.equals("0")!=true){
			sum=0;
			for(int i=0;i<str.length();i++){
				String a=str.substring(i, i+1);
				int n=Integer.parseInt(a);
				sum+=n;
			}
			System.out.println(sum);
			str=br.readLine();
		}
	}
}