import java.util.Scanner;


public class Main {

	public static void main(String [] args) {

		Scanner sc = new Scanner(System.in);
long sum = 0;
String moji = "";
long kou = 0;


		while(true) {

			String i = sc.next();
			moji = i;
			
			if(moji.length() == 1) {
				if(Integer.parseInt(i) == 0)break;
			}

			
			
			 
			 
			 int len = moji.length();
			 
			 
			
			for(int k = 0;k < len;k++) {
				
				char ichi;
				
				
				ichi = moji.charAt(k);
				
				
				kou = Character.getNumericValue(ichi);
				
				sum = sum + kou;
				
				
				
			}
			
			System.out.println(sum);
			
			
			sum = 0;
			moji = "";
			kou = 0;
			

		}

		}



}
 import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String [] args) {

		Scanner sc = new Scanner(System.in);
long sum = 0;
String moji = "";
long kou = 0;


		while(true) {

			String i = sc.next();
			moji = i;
			
			if(moji.length() == 1) {
				if(Integer.parseInt(i) == 0)break;
			}

			
			
			 
			 
			 int len = moji.length();
			 
			 
			
			for(int k = 0;k < len;k++) {
				
				char ichi;
				
				
				ichi = moji.charAt(k);
				
				
				kou = Character.getNumericValue(ichi);
				
				sum = sum + kou;
				
				
				
			}
			
			System.out.println(sum);
			
			
			sum = 0;
			moji = "";
			kou = 0;
			

		}

		}



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

		Scanner sc = new Scanner(System.in);
long sum = 0;
String moji = "";
long kou = 0;


		while(true) {

			String i = sc.next();
			moji = i;
			
			if(moji.length() == 1) {
				if(Integer.parseInt(i) == 0)break;
			}

			
			
			 
			 
			 int len = moji.length();
			 
			 
			
			for(int k = 0;k < len;k++) {
				
				char ichi;
				
				
				ichi = moji.charAt(k);
				
				
				kou = Character.getNumericValue(ichi);
				
				sum = sum + kou;
				
				
				
			}
			
			System.out.println(sum);
			
			
			sum = 0;
			moji = "";
			kou = 0;
			

		}

		} main {

		Scanner sc = new Scanner(System.in);
long sum = 0;
String moji = "";
long kou = 0;


		while(true) {

			String i = sc.next();
			moji = i;
			
			if(moji.length() == 1) {
				if(Integer.parseInt(i) == 0)break;
			}

			
			
			 
			 
			 int len = moji.length();
			 
			 
			
			for(int k = 0;k < len;k++) {
				
				char ichi;
				
				
				ichi = moji.charAt(k);
				
				
				kou = Character.getNumericValue(ichi);
				
				sum = sum + kou;
				
				
				
			}
			
			System.out.println(sum);
			
			
			sum = 0;
			moji = "";
			kou = 0;
			

		}

		} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long sum = 0; sum 0 String moji = ""; moji "" long kou = 0; kou 0 while(true) {

			String i = sc.next();
			moji = i;
			
			if(moji.length() == 1) {
				if(Integer.parseInt(i) == 0)break;
			}

			
			
			 
			 
			 int len = moji.length();
			 
			 
			
			for(int k = 0;k < len;k++) {
				
				char ichi;
				
				
				ichi = moji.charAt(k);
				
				
				kou = Character.getNumericValue(ichi);
				
				sum = sum + kou;
				
				
				
			}
			
			System.out.println(sum);
			
			
			sum = 0;
			moji = "";
			kou = 0;
			

		} true {

			String i = sc.next();
			moji = i;
			
			if(moji.length() == 1) {
				if(Integer.parseInt(i) == 0)break;
			}

			
			
			 
			 
			 int len = moji.length();
			 
			 
			
			for(int k = 0;k < len;k++) {
				
				char ichi;
				
				
				ichi = moji.charAt(k);
				
				
				kou = Character.getNumericValue(ichi);
				
				sum = sum + kou;
				
				
				
			}
			
			System.out.println(sum);
			
			
			sum = 0;
			moji = "";
			kou = 0;
			

		} String i = sc.next(); i sc.next() sc.next sc moji = i moji i if(moji.length() == 1) {
				if(Integer.parseInt(i) == 0)break;
			} moji.length() == 1 moji.length() moji.length moji 1 {
				if(Integer.parseInt(i) == 0)break;
			} if(Integer.parseInt(i) == 0)break; Integer.parseInt(i) == 0 Integer.parseInt(i) Integer.parseInt Integer i 0 break; int len = moji.length(); len moji.length() moji.length moji for(int k = 0;k < len;k++) {
				
				char ichi;
				
				
				ichi = moji.charAt(k);
				
				
				kou = Character.getNumericValue(ichi);
				
				sum = sum + kou;
				
				
				
			} int k = 0; int k = 0; k 0 k < len k len k++ k++ k {
				
				char ichi;
				
				
				ichi = moji.charAt(k);
				
				
				kou = Character.getNumericValue(ichi);
				
				sum = sum + kou;
				
				
				
			} {
				
				char ichi;
				
				
				ichi = moji.charAt(k);
				
				
				kou = Character.getNumericValue(ichi);
				
				sum = sum + kou;
				
				
				
			} char ichi; ichi ichi = moji.charAt(k) ichi moji.charAt(k) moji.charAt moji k kou = Character.getNumericValue(ichi) kou Character.getNumericValue(ichi) Character.getNumericValue Character ichi sum = sum + kou sum sum + kou sum kou System.out.println(sum) System.out.println System.out System System.out sum sum = 0 sum 0 moji = "" moji "" kou = 0 kou 0 String [] args args public class Main {

	public static void main(String [] args) {

		Scanner sc = new Scanner(System.in);
long sum = 0;
String moji = "";
long kou = 0;


		while(true) {

			String i = sc.next();
			moji = i;
			
			if(moji.length() == 1) {
				if(Integer.parseInt(i) == 0)break;
			}

			
			
			 
			 
			 int len = moji.length();
			 
			 
			
			for(int k = 0;k < len;k++) {
				
				char ichi;
				
				
				ichi = moji.charAt(k);
				
				
				kou = Character.getNumericValue(ichi);
				
				sum = sum + kou;
				
				
				
			}
			
			System.out.println(sum);
			
			
			sum = 0;
			moji = "";
			kou = 0;
			

		}

		}



} public class Main {

	public static void main(String [] args) {

		Scanner sc = new Scanner(System.in);
long sum = 0;
String moji = "";
long kou = 0;


		while(true) {

			String i = sc.next();
			moji = i;
			
			if(moji.length() == 1) {
				if(Integer.parseInt(i) == 0)break;
			}

			
			
			 
			 
			 int len = moji.length();
			 
			 
			
			for(int k = 0;k < len;k++) {
				
				char ichi;
				
				
				ichi = moji.charAt(k);
				
				
				kou = Character.getNumericValue(ichi);
				
				sum = sum + kou;
				
				
				
			}
			
			System.out.println(sum);
			
			
			sum = 0;
			moji = "";
			kou = 0;
			

		}

		}



} Main
import java.util.Scanner;


public class Main {

	public static void main(String [] args) {

		Scanner sc = new Scanner(System.in);
long sum = 0;
String moji = "";
long kou = 0;


		while(true) {

			String i = sc.next();
			moji = i;
			
			if(moji.length() == 1) {
				if(Integer.parseInt(i) == 0)break;
			}

			
			
			 
			 
			 int len = moji.length();
			 
			 
			
			for(int k = 0;k < len;k++) {
				
				char ichi;
				
				
				ichi = moji.charAt(k);
				
				
				kou = Character.getNumericValue(ichi);
				
				sum = sum + kou;
				
				
				
			}
			
			System.out.println(sum);
			
			
			sum = 0;
			moji = "";
			kou = 0;
			

		}

		}



}

