import java.util.Scanner;

public class Main {
	 public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 while(true){
			 String x=sc.nextLine();
			 if(x.equals("0"))break;
			 int sum=0;
			 for (char y:x.toCharArray()) {
				 sum +=Integer.parseInt(String.valueOf(y));
			 }

		 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){
			 String x=sc.nextLine();
			 if(x.equals("0"))break;
			 int sum=0;
			 for (char y:x.toCharArray()) {
				 sum +=Integer.parseInt(String.valueOf(y));
			 }

		 System.out.println(sum);
		 }
		 sc.close();
	 }
} Main public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 while(true){
			 String x=sc.nextLine();
			 if(x.equals("0"))break;
			 int sum=0;
			 for (char y:x.toCharArray()) {
				 sum +=Integer.parseInt(String.valueOf(y));
			 }

		 System.out.println(sum);
		 }
		 sc.close();
	 } main {
		 Scanner sc = new Scanner(System.in);
		 while(true){
			 String x=sc.nextLine();
			 if(x.equals("0"))break;
			 int sum=0;
			 for (char y:x.toCharArray()) {
				 sum +=Integer.parseInt(String.valueOf(y));
			 }

		 System.out.println(sum);
		 }
		 sc.close();
	 } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
			 String x=sc.nextLine();
			 if(x.equals("0"))break;
			 int sum=0;
			 for (char y:x.toCharArray()) {
				 sum +=Integer.parseInt(String.valueOf(y));
			 }

		 System.out.println(sum);
		 } true {
			 String x=sc.nextLine();
			 if(x.equals("0"))break;
			 int sum=0;
			 for (char y:x.toCharArray()) {
				 sum +=Integer.parseInt(String.valueOf(y));
			 }

		 System.out.println(sum);
		 } String x=sc.nextLine(); x sc.nextLine() sc.nextLine sc if(x.equals("0"))break; x.equals("0") x.equals x "0" break; int sum=0; sum 0 for (char y:x.toCharArray()) {
				 sum +=Integer.parseInt(String.valueOf(y));
			 } char y x.toCharArray() x.toCharArray x {
				 sum +=Integer.parseInt(String.valueOf(y));
			 } {
				 sum +=Integer.parseInt(String.valueOf(y));
			 } sum +=Integer.parseInt(String.valueOf(y)) sum Integer.parseInt(String.valueOf(y)) Integer.parseInt Integer String.valueOf(y) String.valueOf String y 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){
			 String x=sc.nextLine();
			 if(x.equals("0"))break;
			 int sum=0;
			 for (char y:x.toCharArray()) {
				 sum +=Integer.parseInt(String.valueOf(y));
			 }

		 System.out.println(sum);
		 }
		 sc.close();
	 }
} public class Main {
	 public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 while(true){
			 String x=sc.nextLine();
			 if(x.equals("0"))break;
			 int sum=0;
			 for (char y:x.toCharArray()) {
				 sum +=Integer.parseInt(String.valueOf(y));
			 }

		 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){
			 String x=sc.nextLine();
			 if(x.equals("0"))break;
			 int sum=0;
			 for (char y:x.toCharArray()) {
				 sum +=Integer.parseInt(String.valueOf(y));
			 }

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

