import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		while(true){

			//1??????????????????
			String s = sc.nextLine();

			if(s.equals("0")){
				break;
			}


			char [] cha = s.toCharArray();
			int sum = 0;

			for(int i = 0; i < cha.length; i++){
				//System.out.println(cha[i]);
				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		}
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		while(true){

			//1??????????????????
			String s = sc.nextLine();

			if(s.equals("0")){
				break;
			}


			char [] cha = s.toCharArray();
			int sum = 0;

			for(int i = 0; i < cha.length; i++){
				//System.out.println(cha[i]);
				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		}
		sc.close();
	}
} Main public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		while(true){

			//1??????????????????
			String s = sc.nextLine();

			if(s.equals("0")){
				break;
			}


			char [] cha = s.toCharArray();
			int sum = 0;

			for(int i = 0; i < cha.length; i++){
				//System.out.println(cha[i]);
				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		}
		sc.close();
	} main {

		Scanner sc = new Scanner(System.in);
		while(true){

			//1??????????????????
			String s = sc.nextLine();

			if(s.equals("0")){
				break;
			}


			char [] cha = s.toCharArray();
			int sum = 0;

			for(int i = 0; i < cha.length; i++){
				//System.out.println(cha[i]);
				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		}
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){

			//1??????????????????
			String s = sc.nextLine();

			if(s.equals("0")){
				break;
			}


			char [] cha = s.toCharArray();
			int sum = 0;

			for(int i = 0; i < cha.length; i++){
				//System.out.println(cha[i]);
				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		} true {

			//1??????????????????
			String s = sc.nextLine();

			if(s.equals("0")){
				break;
			}


			char [] cha = s.toCharArray();
			int sum = 0;

			for(int i = 0; i < cha.length; i++){
				//System.out.println(cha[i]);
				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		} String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc if(s.equals("0")){
				break;
			} s.equals("0") s.equals s "0" {
				break;
			} break; char [] cha = s.toCharArray(); cha s.toCharArray() s.toCharArray s int sum = 0; sum 0 for(int i = 0; i < cha.length; i++){
				//System.out.println(cha[i]);
				sum += Character.getNumericValue(cha[i]);
			} int i = 0; int i = 0; i 0 i < cha.length i cha.length cha cha.length i++ i++ i {
				//System.out.println(cha[i]);
				sum += Character.getNumericValue(cha[i]);
			} {
				//System.out.println(cha[i]);
				sum += Character.getNumericValue(cha[i]);
			} sum += Character.getNumericValue(cha[i]) sum Character.getNumericValue(cha[i]) Character.getNumericValue Character cha[i] cha i System.out.println(sum) System.out.println System.out System System.out sum sc.close() sc.close sc String args[] args public class Main{
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		while(true){

			//1??????????????????
			String s = sc.nextLine();

			if(s.equals("0")){
				break;
			}


			char [] cha = s.toCharArray();
			int sum = 0;

			for(int i = 0; i < cha.length; i++){
				//System.out.println(cha[i]);
				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		}
		sc.close();
	}
} public class Main{
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		while(true){

			//1??????????????????
			String s = sc.nextLine();

			if(s.equals("0")){
				break;
			}


			char [] cha = s.toCharArray();
			int sum = 0;

			for(int i = 0; i < cha.length; i++){
				//System.out.println(cha[i]);
				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		}
		sc.close();
	}
} Main
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		while(true){

			//1??????????????????
			String s = sc.nextLine();

			if(s.equals("0")){
				break;
			}


			char [] cha = s.toCharArray();
			int sum = 0;

			for(int i = 0; i < cha.length; i++){
				//System.out.println(cha[i]);
				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		}
		sc.close();
	}
}