import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		ArrayList<String> moji = new ArrayList<String>();
		String mm = "10";
		while(!mm.equals("0")){
			mm = scan.nextLine();
//			String mmToSt = String.valueOf(mm);
			moji.add(mm);
//			System.out.println("scannning");
		}
//		System.out.println("finir");
		for(int i=0; i<moji.size()-1; i++){
			String henkan = moji.get(i);
			char[] ichimoji = henkan.toCharArray();
			long nagasa = henkan.length();
			long sum = 0;
			for(int ii=0; ii<nagasa; ii++){
					sum += Character.getNumericValue(ichimoji[ii]);
			}
			System.out.println(sum);
		}
	}
} import java.io.IOException; IOException java.io import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		ArrayList<String> moji = new ArrayList<String>();
		String mm = "10";
		while(!mm.equals("0")){
			mm = scan.nextLine();
//			String mmToSt = String.valueOf(mm);
			moji.add(mm);
//			System.out.println("scannning");
		}
//		System.out.println("finir");
		for(int i=0; i<moji.size()-1; i++){
			String henkan = moji.get(i);
			char[] ichimoji = henkan.toCharArray();
			long nagasa = henkan.length();
			long sum = 0;
			for(int ii=0; ii<nagasa; ii++){
					sum += Character.getNumericValue(ichimoji[ii]);
			}
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		ArrayList<String> moji = new ArrayList<String>();
		String mm = "10";
		while(!mm.equals("0")){
			mm = scan.nextLine();
//			String mmToSt = String.valueOf(mm);
			moji.add(mm);
//			System.out.println("scannning");
		}
//		System.out.println("finir");
		for(int i=0; i<moji.size()-1; i++){
			String henkan = moji.get(i);
			char[] ichimoji = henkan.toCharArray();
			long nagasa = henkan.length();
			long sum = 0;
			for(int ii=0; ii<nagasa; ii++){
					sum += Character.getNumericValue(ichimoji[ii]);
			}
			System.out.println(sum);
		}
	} main {
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		ArrayList<String> moji = new ArrayList<String>();
		String mm = "10";
		while(!mm.equals("0")){
			mm = scan.nextLine();
//			String mmToSt = String.valueOf(mm);
			moji.add(mm);
//			System.out.println("scannning");
		}
//		System.out.println("finir");
		for(int i=0; i<moji.size()-1; i++){
			String henkan = moji.get(i);
			char[] ichimoji = henkan.toCharArray();
			long nagasa = henkan.length();
			long sum = 0;
			for(int ii=0; ii<nagasa; ii++){
					sum += Character.getNumericValue(ichimoji[ii]);
			}
			System.out.println(sum);
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) ArrayList<String> moji = new ArrayList<String>(); moji new ArrayList<String>() String mm = "10"; mm "10" while(!mm.equals("0")){
			mm = scan.nextLine();
//			String mmToSt = String.valueOf(mm);
			moji.add(mm);
//			System.out.println("scannning");
		} !mm.equals("0") mm.equals("0") mm.equals mm "0" {
			mm = scan.nextLine();
//			String mmToSt = String.valueOf(mm);
			moji.add(mm);
//			System.out.println("scannning");
		} mm = scan.nextLine() mm scan.nextLine() scan.nextLine scan moji.add(mm) moji.add moji mm for(int i=0; i<moji.size()-1; i++){
			String henkan = moji.get(i);
			char[] ichimoji = henkan.toCharArray();
			long nagasa = henkan.length();
			long sum = 0;
			for(int ii=0; ii<nagasa; ii++){
					sum += Character.getNumericValue(ichimoji[ii]);
			}
			System.out.println(sum);
		} int i=0; int i=0; i 0 i<moji.size()-1 i moji.size()-1 moji.size() moji.size moji 1 i++ i++ i {
			String henkan = moji.get(i);
			char[] ichimoji = henkan.toCharArray();
			long nagasa = henkan.length();
			long sum = 0;
			for(int ii=0; ii<nagasa; ii++){
					sum += Character.getNumericValue(ichimoji[ii]);
			}
			System.out.println(sum);
		} {
			String henkan = moji.get(i);
			char[] ichimoji = henkan.toCharArray();
			long nagasa = henkan.length();
			long sum = 0;
			for(int ii=0; ii<nagasa; ii++){
					sum += Character.getNumericValue(ichimoji[ii]);
			}
			System.out.println(sum);
		} String henkan = moji.get(i); henkan moji.get(i) moji.get moji i char[] ichimoji = henkan.toCharArray(); ichimoji henkan.toCharArray() henkan.toCharArray henkan long nagasa = henkan.length(); nagasa henkan.length() henkan.length henkan long sum = 0; sum 0 for(int ii=0; ii<nagasa; ii++){
					sum += Character.getNumericValue(ichimoji[ii]);
			} int ii=0; int ii=0; ii 0 ii<nagasa ii nagasa ii++ ii++ ii {
					sum += Character.getNumericValue(ichimoji[ii]);
			} {
					sum += Character.getNumericValue(ichimoji[ii]);
			} sum += Character.getNumericValue(ichimoji[ii]) sum Character.getNumericValue(ichimoji[ii]) Character.getNumericValue Character ichimoji[ii] ichimoji ii System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		ArrayList<String> moji = new ArrayList<String>();
		String mm = "10";
		while(!mm.equals("0")){
			mm = scan.nextLine();
//			String mmToSt = String.valueOf(mm);
			moji.add(mm);
//			System.out.println("scannning");
		}
//		System.out.println("finir");
		for(int i=0; i<moji.size()-1; i++){
			String henkan = moji.get(i);
			char[] ichimoji = henkan.toCharArray();
			long nagasa = henkan.length();
			long sum = 0;
			for(int ii=0; ii<nagasa; ii++){
					sum += Character.getNumericValue(ichimoji[ii]);
			}
			System.out.println(sum);
		}
	}
}