

import java.util.*;
import java.io.*;

public class Main {
	public static void main(String args[])throws IOException,NumberFormatException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String str;
		int sum;//????¨????????¨????????????¨
		char c;
		sum = 0;
		
		while(true){
			str=br.readLine();
			
			//String??????long????????????
			if(str.length() == 1){
				if(Integer.parseInt(str) == 0){
				break;
				}
			}
			//?????????????????????
			for(int count = 0;count<str.length();count++){
				//????????????????????????????????????????¶?????????????
				c = str.charAt(count);
				//Char??????String??????Long??????????????????????¨?????¶?????????????
				sum += Integer.parseInt(String.valueOf(c));
			}
		sb.append(sum);
		sb.append("\n");
		sum = 0;//?????????
		}
		
		//????????????????????????????????????("\n")?????¨???
		sb.deleteCharAt(sb.length()-1);
		System.out.println(new String(sb));
		
	}
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
	public static void main(String args[])throws IOException,NumberFormatException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String str;
		int sum;//????¨????????¨????????????¨
		char c;
		sum = 0;
		
		while(true){
			str=br.readLine();
			
			//String??????long????????????
			if(str.length() == 1){
				if(Integer.parseInt(str) == 0){
				break;
				}
			}
			//?????????????????????
			for(int count = 0;count<str.length();count++){
				//????????????????????????????????????????¶?????????????
				c = str.charAt(count);
				//Char??????String??????Long??????????????????????¨?????¶?????????????
				sum += Integer.parseInt(String.valueOf(c));
			}
		sb.append(sum);
		sb.append("\n");
		sum = 0;//?????????
		}
		
		//????????????????????????????????????("\n")?????¨???
		sb.deleteCharAt(sb.length()-1);
		System.out.println(new String(sb));
		
	}
} Main public static void main(String args[])throws IOException,NumberFormatException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String str;
		int sum;//????¨????????¨????????????¨
		char c;
		sum = 0;
		
		while(true){
			str=br.readLine();
			
			//String??????long????????????
			if(str.length() == 1){
				if(Integer.parseInt(str) == 0){
				break;
				}
			}
			//?????????????????????
			for(int count = 0;count<str.length();count++){
				//????????????????????????????????????????¶?????????????
				c = str.charAt(count);
				//Char??????String??????Long??????????????????????¨?????¶?????????????
				sum += Integer.parseInt(String.valueOf(c));
			}
		sb.append(sum);
		sb.append("\n");
		sum = 0;//?????????
		}
		
		//????????????????????????????????????("\n")?????¨???
		sb.deleteCharAt(sb.length()-1);
		System.out.println(new String(sb));
		
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String str;
		int sum;//????¨????????¨????????????¨
		char c;
		sum = 0;
		
		while(true){
			str=br.readLine();
			
			//String??????long????????????
			if(str.length() == 1){
				if(Integer.parseInt(str) == 0){
				break;
				}
			}
			//?????????????????????
			for(int count = 0;count<str.length();count++){
				//????????????????????????????????????????¶?????????????
				c = str.charAt(count);
				//Char??????String??????Long??????????????????????¨?????¶?????????????
				sum += Integer.parseInt(String.valueOf(c));
			}
		sb.append(sum);
		sb.append("\n");
		sum = 0;//?????????
		}
		
		//????????????????????????????????????("\n")?????¨???
		sb.deleteCharAt(sb.length()-1);
		System.out.println(new String(sb));
		
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() String str; str int sum; sum char c; c sum = 0 sum 0 while(true){
			str=br.readLine();
			
			//String??????long????????????
			if(str.length() == 1){
				if(Integer.parseInt(str) == 0){
				break;
				}
			}
			//?????????????????????
			for(int count = 0;count<str.length();count++){
				//????????????????????????????????????????¶?????????????
				c = str.charAt(count);
				//Char??????String??????Long??????????????????????¨?????¶?????????????
				sum += Integer.parseInt(String.valueOf(c));
			}
		sb.append(sum);
		sb.append("\n");
		sum = 0;//?????????
		} true {
			str=br.readLine();
			
			//String??????long????????????
			if(str.length() == 1){
				if(Integer.parseInt(str) == 0){
				break;
				}
			}
			//?????????????????????
			for(int count = 0;count<str.length();count++){
				//????????????????????????????????????????¶?????????????
				c = str.charAt(count);
				//Char??????String??????Long??????????????????????¨?????¶?????????????
				sum += Integer.parseInt(String.valueOf(c));
			}
		sb.append(sum);
		sb.append("\n");
		sum = 0;//?????????
		} str=br.readLine() str br.readLine() br.readLine br if(str.length() == 1){
				if(Integer.parseInt(str) == 0){
				break;
				}
			} str.length() == 1 str.length() str.length str 1 {
				if(Integer.parseInt(str) == 0){
				break;
				}
			} if(Integer.parseInt(str) == 0){
				break;
				} Integer.parseInt(str) == 0 Integer.parseInt(str) Integer.parseInt Integer str 0 {
				break;
				} break; for(int count = 0;count<str.length();count++){
				//????????????????????????????????????????¶?????????????
				c = str.charAt(count);
				//Char??????String??????Long??????????????????????¨?????¶?????????????
				sum += Integer.parseInt(String.valueOf(c));
			} int count = 0; int count = 0; count 0 count<str.length() count str.length() str.length str count++ count++ count {
				//????????????????????????????????????????¶?????????????
				c = str.charAt(count);
				//Char??????String??????Long??????????????????????¨?????¶?????????????
				sum += Integer.parseInt(String.valueOf(c));
			} {
				//????????????????????????????????????????¶?????????????
				c = str.charAt(count);
				//Char??????String??????Long??????????????????????¨?????¶?????????????
				sum += Integer.parseInt(String.valueOf(c));
			} c = str.charAt(count) c str.charAt(count) str.charAt str count sum += Integer.parseInt(String.valueOf(c)) sum Integer.parseInt(String.valueOf(c)) Integer.parseInt Integer String.valueOf(c) String.valueOf String c sb.append(sum) sb.append sb sum sb.append("\n") sb.append sb "\n" sum = 0 sum 0 sb.deleteCharAt(sb.length()-1) sb.deleteCharAt sb sb.length()-1 sb.length() sb.length sb 1 System.out.println(new String(sb)) System.out.println System.out System System.out new String(sb) String args[] args public class Main {
	public static void main(String args[])throws IOException,NumberFormatException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String str;
		int sum;//????¨????????¨????????????¨
		char c;
		sum = 0;
		
		while(true){
			str=br.readLine();
			
			//String??????long????????????
			if(str.length() == 1){
				if(Integer.parseInt(str) == 0){
				break;
				}
			}
			//?????????????????????
			for(int count = 0;count<str.length();count++){
				//????????????????????????????????????????¶?????????????
				c = str.charAt(count);
				//Char??????String??????Long??????????????????????¨?????¶?????????????
				sum += Integer.parseInt(String.valueOf(c));
			}
		sb.append(sum);
		sb.append("\n");
		sum = 0;//?????????
		}
		
		//????????????????????????????????????("\n")?????¨???
		sb.deleteCharAt(sb.length()-1);
		System.out.println(new String(sb));
		
	}
} public class Main {
	public static void main(String args[])throws IOException,NumberFormatException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String str;
		int sum;//????¨????????¨????????????¨
		char c;
		sum = 0;
		
		while(true){
			str=br.readLine();
			
			//String??????long????????????
			if(str.length() == 1){
				if(Integer.parseInt(str) == 0){
				break;
				}
			}
			//?????????????????????
			for(int count = 0;count<str.length();count++){
				//????????????????????????????????????????¶?????????????
				c = str.charAt(count);
				//Char??????String??????Long??????????????????????¨?????¶?????????????
				sum += Integer.parseInt(String.valueOf(c));
			}
		sb.append(sum);
		sb.append("\n");
		sum = 0;//?????????
		}
		
		//????????????????????????????????????("\n")?????¨???
		sb.deleteCharAt(sb.length()-1);
		System.out.println(new String(sb));
		
	}
} Main


import java.util.*;
import java.io.*;

public class Main {
	public static void main(String args[])throws IOException,NumberFormatException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String str;
		int sum;//????¨????????¨????????????¨
		char c;
		sum = 0;
		
		while(true){
			str=br.readLine();
			
			//String??????long????????????
			if(str.length() == 1){
				if(Integer.parseInt(str) == 0){
				break;
				}
			}
			//?????????????????????
			for(int count = 0;count<str.length();count++){
				//????????????????????????????????????????¶?????????????
				c = str.charAt(count);
				//Char??????String??????Long??????????????????????¨?????¶?????????????
				sum += Integer.parseInt(String.valueOf(c));
			}
		sb.append(sum);
		sb.append("\n");
		sum = 0;//?????????
		}
		
		//????????????????????????????????????("\n")?????¨???
		sb.deleteCharAt(sb.length()-1);
		System.out.println(new String(sb));
		
	}
}