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

public class Main {

	public static void main(String[] args) throws IOException {


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		for(;;){

			int sum =0;

			String[] input = br.readLine().split("");

			if(input[0].equals("0")){break;}

			for(int i=0;i<input.length;i++){

				sum += Integer.parseInt(input[i]);


			}System.out.println(sum);



		}



		//??????

	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws IOException {


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		for(;;){

			int sum =0;

			String[] input = br.readLine().split("");

			if(input[0].equals("0")){break;}

			for(int i=0;i<input.length;i++){

				sum += Integer.parseInt(input[i]);


			}System.out.println(sum);



		}



		//??????

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


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		for(;;){

			int sum =0;

			String[] input = br.readLine().split("");

			if(input[0].equals("0")){break;}

			for(int i=0;i<input.length;i++){

				sum += Integer.parseInt(input[i]);


			}System.out.println(sum);



		}



		//??????

	} main {


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		for(;;){

			int sum =0;

			String[] input = br.readLine().split("");

			if(input[0].equals("0")){break;}

			for(int i=0;i<input.length;i++){

				sum += Integer.parseInt(input[i]);


			}System.out.println(sum);



		}



		//??????

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) for(;;){

			int sum =0;

			String[] input = br.readLine().split("");

			if(input[0].equals("0")){break;}

			for(int i=0;i<input.length;i++){

				sum += Integer.parseInt(input[i]);


			}System.out.println(sum);



		} ; {

			int sum =0;

			String[] input = br.readLine().split("");

			if(input[0].equals("0")){break;}

			for(int i=0;i<input.length;i++){

				sum += Integer.parseInt(input[i]);


			}System.out.println(sum);



		} {

			int sum =0;

			String[] input = br.readLine().split("");

			if(input[0].equals("0")){break;}

			for(int i=0;i<input.length;i++){

				sum += Integer.parseInt(input[i]);


			}System.out.println(sum);



		} int sum =0; sum 0 String[] input = br.readLine().split(""); input br.readLine().split("") br.readLine().split br.readLine() br.readLine br "" if(input[0].equals("0")){break;} input[0].equals("0") input[0].equals input[0] input 0 "0" {break;} break; for(int i=0;i<input.length;i++){

				sum += Integer.parseInt(input[i]);


			} int i=0; int i=0; i 0 i<input.length i input.length input input.length i++ i++ i {

				sum += Integer.parseInt(input[i]);


			} {

				sum += Integer.parseInt(input[i]);


			} sum += Integer.parseInt(input[i]) sum Integer.parseInt(input[i]) Integer.parseInt Integer input[i] input i 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) throws IOException {


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		for(;;){

			int sum =0;

			String[] input = br.readLine().split("");

			if(input[0].equals("0")){break;}

			for(int i=0;i<input.length;i++){

				sum += Integer.parseInt(input[i]);


			}System.out.println(sum);



		}



		//??????

	}
} public class Main {

	public static void main(String[] args) throws IOException {


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		for(;;){

			int sum =0;

			String[] input = br.readLine().split("");

			if(input[0].equals("0")){break;}

			for(int i=0;i<input.length;i++){

				sum += Integer.parseInt(input[i]);


			}System.out.println(sum);



		}



		//??????

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

public class Main {

	public static void main(String[] args) throws IOException {


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		for(;;){

			int sum =0;

			String[] input = br.readLine().split("");

			if(input[0].equals("0")){break;}

			for(int i=0;i<input.length;i++){

				sum += Integer.parseInt(input[i]);


			}System.out.println(sum);



		}



		//??????

	}
}