import java.util.Scanner;
public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		String work = "";
		int len,sum;
		work = sc.next();
		len = work.length();
		sum = 0;
		while(true){
			if(work.charAt(0) == '0'){
				break;
			}
			for(int i = 0; i < len; i++){
				sum += Integer.parseInt(work.substring(i,i+1));
			}
			System.out.println(sum);
			work = sc.next();
			len = work.length();
			sum = 0;
		}
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		String work = "";
		int len,sum;
		work = sc.next();
		len = work.length();
		sum = 0;
		while(true){
			if(work.charAt(0) == '0'){
				break;
			}
			for(int i = 0; i < len; i++){
				sum += Integer.parseInt(work.substring(i,i+1));
			}
			System.out.println(sum);
			work = sc.next();
			len = work.length();
			sum = 0;
		}
	}
} Main public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		String work = "";
		int len,sum;
		work = sc.next();
		len = work.length();
		sum = 0;
		while(true){
			if(work.charAt(0) == '0'){
				break;
			}
			for(int i = 0; i < len; i++){
				sum += Integer.parseInt(work.substring(i,i+1));
			}
			System.out.println(sum);
			work = sc.next();
			len = work.length();
			sum = 0;
		}
	} main {
		Scanner sc = new Scanner(System.in);
		String work = "";
		int len,sum;
		work = sc.next();
		len = work.length();
		sum = 0;
		while(true){
			if(work.charAt(0) == '0'){
				break;
			}
			for(int i = 0; i < len; i++){
				sum += Integer.parseInt(work.substring(i,i+1));
			}
			System.out.println(sum);
			work = sc.next();
			len = work.length();
			sum = 0;
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String work = ""; work "" int len len sum; sum work = sc.next() work sc.next() sc.next sc len = work.length() len work.length() work.length work sum = 0 sum 0 while(true){
			if(work.charAt(0) == '0'){
				break;
			}
			for(int i = 0; i < len; i++){
				sum += Integer.parseInt(work.substring(i,i+1));
			}
			System.out.println(sum);
			work = sc.next();
			len = work.length();
			sum = 0;
		} true {
			if(work.charAt(0) == '0'){
				break;
			}
			for(int i = 0; i < len; i++){
				sum += Integer.parseInt(work.substring(i,i+1));
			}
			System.out.println(sum);
			work = sc.next();
			len = work.length();
			sum = 0;
		} if(work.charAt(0) == '0'){
				break;
			} work.charAt(0) == '0' work.charAt(0) work.charAt work 0 '0' {
				break;
			} break; for(int i = 0; i < len; i++){
				sum += Integer.parseInt(work.substring(i,i+1));
			} int i = 0; int i = 0; i 0 i < len i len i++ i++ i {
				sum += Integer.parseInt(work.substring(i,i+1));
			} {
				sum += Integer.parseInt(work.substring(i,i+1));
			} sum += Integer.parseInt(work.substring(i,i+1)) sum Integer.parseInt(work.substring(i,i+1)) Integer.parseInt Integer work.substring(i,i+1) work.substring work i i+1 i 1 System.out.println(sum) System.out.println System.out System System.out sum work = sc.next() work sc.next() sc.next sc len = work.length() len work.length() work.length work sum = 0 sum 0 String [] args args public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		String work = "";
		int len,sum;
		work = sc.next();
		len = work.length();
		sum = 0;
		while(true){
			if(work.charAt(0) == '0'){
				break;
			}
			for(int i = 0; i < len; i++){
				sum += Integer.parseInt(work.substring(i,i+1));
			}
			System.out.println(sum);
			work = sc.next();
			len = work.length();
			sum = 0;
		}
	}
} public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		String work = "";
		int len,sum;
		work = sc.next();
		len = work.length();
		sum = 0;
		while(true){
			if(work.charAt(0) == '0'){
				break;
			}
			for(int i = 0; i < len; i++){
				sum += Integer.parseInt(work.substring(i,i+1));
			}
			System.out.println(sum);
			work = sc.next();
			len = work.length();
			sum = 0;
		}
	}
} Main
import java.util.Scanner;
public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		String work = "";
		int len,sum;
		work = sc.next();
		len = work.length();
		sum = 0;
		while(true){
			if(work.charAt(0) == '0'){
				break;
			}
			for(int i = 0; i < len; i++){
				sum += Integer.parseInt(work.substring(i,i+1));
			}
			System.out.println(sum);
			work = sc.next();
			len = work.length();
			sum = 0;
		}
	}
}