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



public class Main{
	public static void main(String[] args){


		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String s;
		int sum;
		try{
		while(true){
			sum=0;
			String[] s_array;//???????????§?????????1???????????????????????????????????????????????????????????????
			s=reader.readLine();
			s_array=s.split("");
			int[] s_num=new int[s_array.length];
			Arrays.fill(s_num, 0);
			for(int i=0;i<s_array.length;i++){
				s_num[i]=Integer.parseInt(s_array[i]);
				sum+=s_num[i];
			}
			if(sum==0)break;
			System.out.println(sum);
		}




		}catch(IOException e){
			System.out.println(e);
		}

	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Arrays; Arrays java.util public class Main{
	public static void main(String[] args){


		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String s;
		int sum;
		try{
		while(true){
			sum=0;
			String[] s_array;//???????????§?????????1???????????????????????????????????????????????????????????????
			s=reader.readLine();
			s_array=s.split("");
			int[] s_num=new int[s_array.length];
			Arrays.fill(s_num, 0);
			for(int i=0;i<s_array.length;i++){
				s_num[i]=Integer.parseInt(s_array[i]);
				sum+=s_num[i];
			}
			if(sum==0)break;
			System.out.println(sum);
		}




		}catch(IOException e){
			System.out.println(e);
		}

	}
} Main public static void main(String[] args){


		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String s;
		int sum;
		try{
		while(true){
			sum=0;
			String[] s_array;//???????????§?????????1???????????????????????????????????????????????????????????????
			s=reader.readLine();
			s_array=s.split("");
			int[] s_num=new int[s_array.length];
			Arrays.fill(s_num, 0);
			for(int i=0;i<s_array.length;i++){
				s_num[i]=Integer.parseInt(s_array[i]);
				sum+=s_num[i];
			}
			if(sum==0)break;
			System.out.println(sum);
		}




		}catch(IOException e){
			System.out.println(e);
		}

	} main {


		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String s;
		int sum;
		try{
		while(true){
			sum=0;
			String[] s_array;//???????????§?????????1???????????????????????????????????????????????????????????????
			s=reader.readLine();
			s_array=s.split("");
			int[] s_num=new int[s_array.length];
			Arrays.fill(s_num, 0);
			for(int i=0;i<s_array.length;i++){
				s_num[i]=Integer.parseInt(s_array[i]);
				sum+=s_num[i];
			}
			if(sum==0)break;
			System.out.println(sum);
		}




		}catch(IOException e){
			System.out.println(e);
		}

	} BufferedReader reader=new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) String s; s int sum; sum try{
		while(true){
			sum=0;
			String[] s_array;//???????????§?????????1???????????????????????????????????????????????????????????????
			s=reader.readLine();
			s_array=s.split("");
			int[] s_num=new int[s_array.length];
			Arrays.fill(s_num, 0);
			for(int i=0;i<s_array.length;i++){
				s_num[i]=Integer.parseInt(s_array[i]);
				sum+=s_num[i];
			}
			if(sum==0)break;
			System.out.println(sum);
		}




		}catch(IOException e){
			System.out.println(e);
		} catch(IOException e){
			System.out.println(e);
		} IOException e {
			System.out.println(e);
		} System.out.println(e) System.out.println System.out System System.out e {
		while(true){
			sum=0;
			String[] s_array;//???????????§?????????1???????????????????????????????????????????????????????????????
			s=reader.readLine();
			s_array=s.split("");
			int[] s_num=new int[s_array.length];
			Arrays.fill(s_num, 0);
			for(int i=0;i<s_array.length;i++){
				s_num[i]=Integer.parseInt(s_array[i]);
				sum+=s_num[i];
			}
			if(sum==0)break;
			System.out.println(sum);
		}




		} while(true){
			sum=0;
			String[] s_array;//???????????§?????????1???????????????????????????????????????????????????????????????
			s=reader.readLine();
			s_array=s.split("");
			int[] s_num=new int[s_array.length];
			Arrays.fill(s_num, 0);
			for(int i=0;i<s_array.length;i++){
				s_num[i]=Integer.parseInt(s_array[i]);
				sum+=s_num[i];
			}
			if(sum==0)break;
			System.out.println(sum);
		} true {
			sum=0;
			String[] s_array;//???????????§?????????1???????????????????????????????????????????????????????????????
			s=reader.readLine();
			s_array=s.split("");
			int[] s_num=new int[s_array.length];
			Arrays.fill(s_num, 0);
			for(int i=0;i<s_array.length;i++){
				s_num[i]=Integer.parseInt(s_array[i]);
				sum+=s_num[i];
			}
			if(sum==0)break;
			System.out.println(sum);
		} sum=0 sum 0 String[] s_array; s_array s=reader.readLine() s reader.readLine() reader.readLine reader s_array=s.split("") s_array s.split("") s.split s "" int[] s_num=new int[s_array.length]; s_num new int[s_array.length] s_array.length s_array s_array.length Arrays.fill(s_num, 0) Arrays.fill Arrays s_num 0 for(int i=0;i<s_array.length;i++){
				s_num[i]=Integer.parseInt(s_array[i]);
				sum+=s_num[i];
			} int i=0; int i=0; i 0 i<s_array.length i s_array.length s_array s_array.length i++ i++ i {
				s_num[i]=Integer.parseInt(s_array[i]);
				sum+=s_num[i];
			} {
				s_num[i]=Integer.parseInt(s_array[i]);
				sum+=s_num[i];
			} s_num[i]=Integer.parseInt(s_array[i]) s_num[i] s_num i Integer.parseInt(s_array[i]) Integer.parseInt Integer s_array[i] s_array i sum+=s_num[i] sum s_num[i] s_num i if(sum==0)break; sum==0 sum 0 break; 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 reader=new BufferedReader(new InputStreamReader(System.in));
		String s;
		int sum;
		try{
		while(true){
			sum=0;
			String[] s_array;//???????????§?????????1???????????????????????????????????????????????????????????????
			s=reader.readLine();
			s_array=s.split("");
			int[] s_num=new int[s_array.length];
			Arrays.fill(s_num, 0);
			for(int i=0;i<s_array.length;i++){
				s_num[i]=Integer.parseInt(s_array[i]);
				sum+=s_num[i];
			}
			if(sum==0)break;
			System.out.println(sum);
		}




		}catch(IOException e){
			System.out.println(e);
		}

	}
} public class Main{
	public static void main(String[] args){


		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String s;
		int sum;
		try{
		while(true){
			sum=0;
			String[] s_array;//???????????§?????????1???????????????????????????????????????????????????????????????
			s=reader.readLine();
			s_array=s.split("");
			int[] s_num=new int[s_array.length];
			Arrays.fill(s_num, 0);
			for(int i=0;i<s_array.length;i++){
				s_num[i]=Integer.parseInt(s_array[i]);
				sum+=s_num[i];
			}
			if(sum==0)break;
			System.out.println(sum);
		}




		}catch(IOException e){
			System.out.println(e);
		}

	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;



public class Main{
	public static void main(String[] args){


		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String s;
		int sum;
		try{
		while(true){
			sum=0;
			String[] s_array;//???????????§?????????1???????????????????????????????????????????????????????????????
			s=reader.readLine();
			s_array=s.split("");
			int[] s_num=new int[s_array.length];
			Arrays.fill(s_num, 0);
			for(int i=0;i<s_array.length;i++){
				s_num[i]=Integer.parseInt(s_array[i]);
				sum+=s_num[i];
			}
			if(sum==0)break;
			System.out.println(sum);
		}




		}catch(IOException e){
			System.out.println(e);
		}

	}
}