import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	
	public static void main(String[] args){
		
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		//?????????????????????char[]?????¬????????§??????????´????????????????list??????
		ArrayList<char[]> list = new ArrayList<char[]>();
		
		try {
			boolean isContinue = true;
			while(isContinue){
				
				String strLine = insBR.readLine();
				if(!"0".equals(strLine)){
					//?????§???????????°???char[]???????§£??????list???????´?
					char[] ary = strLine.toCharArray(); 
					list.add(ary);
				}else{
					isContinue = false;
				}
			}
		} catch (IOException e) {
			// TODO ????????????????????? catch ????????????
			e.printStackTrace();
		}
		
		//char[]???int[]?????\?????´???
		
		for(int i = 0; i < list.size(); i++){
			//?????????????¨?????????\???????????°
			int intSumNum = 0;
					
			char[] ary = list.get(i);
			for(int j = 0; j < ary.length; j++){
				//char??????int??????????????????????????????
				int intNum = 0;
				intNum = Character.getNumericValue(ary[j]);
				intSumNum += intNum;
			}
			//??????
			System.out.println(intSumNum);
		}
		
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util public class Main {
	
	public static void main(String[] args){
		
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		//?????????????????????char[]?????¬????????§??????????´????????????????list??????
		ArrayList<char[]> list = new ArrayList<char[]>();
		
		try {
			boolean isContinue = true;
			while(isContinue){
				
				String strLine = insBR.readLine();
				if(!"0".equals(strLine)){
					//?????§???????????°???char[]???????§£??????list???????´?
					char[] ary = strLine.toCharArray(); 
					list.add(ary);
				}else{
					isContinue = false;
				}
			}
		} catch (IOException e) {
			// TODO ????????????????????? catch ????????????
			e.printStackTrace();
		}
		
		//char[]???int[]?????\?????´???
		
		for(int i = 0; i < list.size(); i++){
			//?????????????¨?????????\???????????°
			int intSumNum = 0;
					
			char[] ary = list.get(i);
			for(int j = 0; j < ary.length; j++){
				//char??????int??????????????????????????????
				int intNum = 0;
				intNum = Character.getNumericValue(ary[j]);
				intSumNum += intNum;
			}
			//??????
			System.out.println(intSumNum);
		}
		
	}
} Main public static void main(String[] args){
		
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		//?????????????????????char[]?????¬????????§??????????´????????????????list??????
		ArrayList<char[]> list = new ArrayList<char[]>();
		
		try {
			boolean isContinue = true;
			while(isContinue){
				
				String strLine = insBR.readLine();
				if(!"0".equals(strLine)){
					//?????§???????????°???char[]???????§£??????list???????´?
					char[] ary = strLine.toCharArray(); 
					list.add(ary);
				}else{
					isContinue = false;
				}
			}
		} catch (IOException e) {
			// TODO ????????????????????? catch ????????????
			e.printStackTrace();
		}
		
		//char[]???int[]?????\?????´???
		
		for(int i = 0; i < list.size(); i++){
			//?????????????¨?????????\???????????°
			int intSumNum = 0;
					
			char[] ary = list.get(i);
			for(int j = 0; j < ary.length; j++){
				//char??????int??????????????????????????????
				int intNum = 0;
				intNum = Character.getNumericValue(ary[j]);
				intSumNum += intNum;
			}
			//??????
			System.out.println(intSumNum);
		}
		
	} main {
		
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		//?????????????????????char[]?????¬????????§??????????´????????????????list??????
		ArrayList<char[]> list = new ArrayList<char[]>();
		
		try {
			boolean isContinue = true;
			while(isContinue){
				
				String strLine = insBR.readLine();
				if(!"0".equals(strLine)){
					//?????§???????????°???char[]???????§£??????list???????´?
					char[] ary = strLine.toCharArray(); 
					list.add(ary);
				}else{
					isContinue = false;
				}
			}
		} catch (IOException e) {
			// TODO ????????????????????? catch ????????????
			e.printStackTrace();
		}
		
		//char[]???int[]?????\?????´???
		
		for(int i = 0; i < list.size(); i++){
			//?????????????¨?????????\???????????°
			int intSumNum = 0;
					
			char[] ary = list.get(i);
			for(int j = 0; j < ary.length; j++){
				//char??????int??????????????????????????????
				int intNum = 0;
				intNum = Character.getNumericValue(ary[j]);
				intSumNum += intNum;
			}
			//??????
			System.out.println(intSumNum);
		}
		
	} BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in)); insBR new BufferedReader(new InputStreamReader(System.in)) ArrayList<char[]> list = new ArrayList<char[]>(); list new ArrayList<char[]>() try {
			boolean isContinue = true;
			while(isContinue){
				
				String strLine = insBR.readLine();
				if(!"0".equals(strLine)){
					//?????§???????????°???char[]???????§£??????list???????´?
					char[] ary = strLine.toCharArray(); 
					list.add(ary);
				}else{
					isContinue = false;
				}
			}
		} catch (IOException e) {
			// TODO ????????????????????? catch ????????????
			e.printStackTrace();
		} catch (IOException e) {
			// TODO ????????????????????? catch ????????????
			e.printStackTrace();
		} IOException e {
			// TODO ????????????????????? catch ????????????
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			boolean isContinue = true;
			while(isContinue){
				
				String strLine = insBR.readLine();
				if(!"0".equals(strLine)){
					//?????§???????????°???char[]???????§£??????list???????´?
					char[] ary = strLine.toCharArray(); 
					list.add(ary);
				}else{
					isContinue = false;
				}
			}
		} boolean isContinue = true; isContinue true while(isContinue){
				
				String strLine = insBR.readLine();
				if(!"0".equals(strLine)){
					//?????§???????????°???char[]???????§£??????list???????´?
					char[] ary = strLine.toCharArray(); 
					list.add(ary);
				}else{
					isContinue = false;
				}
			} isContinue {
				
				String strLine = insBR.readLine();
				if(!"0".equals(strLine)){
					//?????§???????????°???char[]???????§£??????list???????´?
					char[] ary = strLine.toCharArray(); 
					list.add(ary);
				}else{
					isContinue = false;
				}
			} String strLine = insBR.readLine(); strLine insBR.readLine() insBR.readLine insBR if(!"0".equals(strLine)){
					//?????§???????????°???char[]???????§£??????list???????´?
					char[] ary = strLine.toCharArray(); 
					list.add(ary);
				}else{
					isContinue = false;
				} !"0".equals(strLine) "0".equals(strLine) "0".equals "0" strLine {
					//?????§???????????°???char[]???????§£??????list???????´?
					char[] ary = strLine.toCharArray(); 
					list.add(ary);
				} char[] ary = strLine.toCharArray(); ary strLine.toCharArray() strLine.toCharArray strLine list.add(ary) list.add list ary {
					isContinue = false;
				} isContinue = false isContinue false for(int i = 0; i < list.size(); i++){
			//?????????????¨?????????\???????????°
			int intSumNum = 0;
					
			char[] ary = list.get(i);
			for(int j = 0; j < ary.length; j++){
				//char??????int??????????????????????????????
				int intNum = 0;
				intNum = Character.getNumericValue(ary[j]);
				intSumNum += intNum;
			}
			//??????
			System.out.println(intSumNum);
		} int i = 0; int i = 0; i 0 i < list.size() i list.size() list.size list i++ i++ i {
			//?????????????¨?????????\???????????°
			int intSumNum = 0;
					
			char[] ary = list.get(i);
			for(int j = 0; j < ary.length; j++){
				//char??????int??????????????????????????????
				int intNum = 0;
				intNum = Character.getNumericValue(ary[j]);
				intSumNum += intNum;
			}
			//??????
			System.out.println(intSumNum);
		} {
			//?????????????¨?????????\???????????°
			int intSumNum = 0;
					
			char[] ary = list.get(i);
			for(int j = 0; j < ary.length; j++){
				//char??????int??????????????????????????????
				int intNum = 0;
				intNum = Character.getNumericValue(ary[j]);
				intSumNum += intNum;
			}
			//??????
			System.out.println(intSumNum);
		} int intSumNum = 0; intSumNum 0 char[] ary = list.get(i); ary list.get(i) list.get list i for(int j = 0; j < ary.length; j++){
				//char??????int??????????????????????????????
				int intNum = 0;
				intNum = Character.getNumericValue(ary[j]);
				intSumNum += intNum;
			} int j = 0; int j = 0; j 0 j < ary.length j ary.length ary ary.length j++ j++ j {
				//char??????int??????????????????????????????
				int intNum = 0;
				intNum = Character.getNumericValue(ary[j]);
				intSumNum += intNum;
			} {
				//char??????int??????????????????????????????
				int intNum = 0;
				intNum = Character.getNumericValue(ary[j]);
				intSumNum += intNum;
			} int intNum = 0; intNum 0 intNum = Character.getNumericValue(ary[j]) intNum Character.getNumericValue(ary[j]) Character.getNumericValue Character ary[j] ary j intSumNum += intNum intSumNum intNum System.out.println(intSumNum) System.out.println System.out System System.out intSumNum String[] args args public class Main {
	
	public static void main(String[] args){
		
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		//?????????????????????char[]?????¬????????§??????????´????????????????list??????
		ArrayList<char[]> list = new ArrayList<char[]>();
		
		try {
			boolean isContinue = true;
			while(isContinue){
				
				String strLine = insBR.readLine();
				if(!"0".equals(strLine)){
					//?????§???????????°???char[]???????§£??????list???????´?
					char[] ary = strLine.toCharArray(); 
					list.add(ary);
				}else{
					isContinue = false;
				}
			}
		} catch (IOException e) {
			// TODO ????????????????????? catch ????????????
			e.printStackTrace();
		}
		
		//char[]???int[]?????\?????´???
		
		for(int i = 0; i < list.size(); i++){
			//?????????????¨?????????\???????????°
			int intSumNum = 0;
					
			char[] ary = list.get(i);
			for(int j = 0; j < ary.length; j++){
				//char??????int??????????????????????????????
				int intNum = 0;
				intNum = Character.getNumericValue(ary[j]);
				intSumNum += intNum;
			}
			//??????
			System.out.println(intSumNum);
		}
		
	}
} public class Main {
	
	public static void main(String[] args){
		
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		//?????????????????????char[]?????¬????????§??????????´????????????????list??????
		ArrayList<char[]> list = new ArrayList<char[]>();
		
		try {
			boolean isContinue = true;
			while(isContinue){
				
				String strLine = insBR.readLine();
				if(!"0".equals(strLine)){
					//?????§???????????°???char[]???????§£??????list???????´?
					char[] ary = strLine.toCharArray(); 
					list.add(ary);
				}else{
					isContinue = false;
				}
			}
		} catch (IOException e) {
			// TODO ????????????????????? catch ????????????
			e.printStackTrace();
		}
		
		//char[]???int[]?????\?????´???
		
		for(int i = 0; i < list.size(); i++){
			//?????????????¨?????????\???????????°
			int intSumNum = 0;
					
			char[] ary = list.get(i);
			for(int j = 0; j < ary.length; j++){
				//char??????int??????????????????????????????
				int intNum = 0;
				intNum = Character.getNumericValue(ary[j]);
				intSumNum += intNum;
			}
			//??????
			System.out.println(intSumNum);
		}
		
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	
	public static void main(String[] args){
		
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		//?????????????????????char[]?????¬????????§??????????´????????????????list??????
		ArrayList<char[]> list = new ArrayList<char[]>();
		
		try {
			boolean isContinue = true;
			while(isContinue){
				
				String strLine = insBR.readLine();
				if(!"0".equals(strLine)){
					//?????§???????????°???char[]???????§£??????list???????´?
					char[] ary = strLine.toCharArray(); 
					list.add(ary);
				}else{
					isContinue = false;
				}
			}
		} catch (IOException e) {
			// TODO ????????????????????? catch ????????????
			e.printStackTrace();
		}
		
		//char[]???int[]?????\?????´???
		
		for(int i = 0; i < list.size(); i++){
			//?????????????¨?????????\???????????°
			int intSumNum = 0;
					
			char[] ary = list.get(i);
			for(int j = 0; j < ary.length; j++){
				//char??????int??????????????????????????????
				int intNum = 0;
				intNum = Character.getNumericValue(ary[j]);
				intSumNum += intNum;
			}
			//??????
			System.out.println(intSumNum);
		}
		
	}
}