import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<Integer> list = new ArrayList<Integer>();
		for(;;){
			String number = scan.next();
			if(number.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < number.length(); i++){
				char ch = number.charAt(i);
				String c = String.valueOf(ch);
				int n = Integer.parseInt(c);
				sum += n;
			}
			list.add(sum);
		}

		for(int n : list){
			System.out.println(n);
		}
	}
} import java.util.*; util.* java public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<Integer> list = new ArrayList<Integer>();
		for(;;){
			String number = scan.next();
			if(number.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < number.length(); i++){
				char ch = number.charAt(i);
				String c = String.valueOf(ch);
				int n = Integer.parseInt(c);
				sum += n;
			}
			list.add(sum);
		}

		for(int n : list){
			System.out.println(n);
		}
	}
} Main private static final Scanner scan = new Scanner(System.in); scan new Scanner(System.in) public static void main(String[] args){
		List<Integer> list = new ArrayList<Integer>();
		for(;;){
			String number = scan.next();
			if(number.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < number.length(); i++){
				char ch = number.charAt(i);
				String c = String.valueOf(ch);
				int n = Integer.parseInt(c);
				sum += n;
			}
			list.add(sum);
		}

		for(int n : list){
			System.out.println(n);
		}
	} main {
		List<Integer> list = new ArrayList<Integer>();
		for(;;){
			String number = scan.next();
			if(number.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < number.length(); i++){
				char ch = number.charAt(i);
				String c = String.valueOf(ch);
				int n = Integer.parseInt(c);
				sum += n;
			}
			list.add(sum);
		}

		for(int n : list){
			System.out.println(n);
		}
	} List<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for(;;){
			String number = scan.next();
			if(number.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < number.length(); i++){
				char ch = number.charAt(i);
				String c = String.valueOf(ch);
				int n = Integer.parseInt(c);
				sum += n;
			}
			list.add(sum);
		} ; {
			String number = scan.next();
			if(number.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < number.length(); i++){
				char ch = number.charAt(i);
				String c = String.valueOf(ch);
				int n = Integer.parseInt(c);
				sum += n;
			}
			list.add(sum);
		} {
			String number = scan.next();
			if(number.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < number.length(); i++){
				char ch = number.charAt(i);
				String c = String.valueOf(ch);
				int n = Integer.parseInt(c);
				sum += n;
			}
			list.add(sum);
		} String number = scan.next(); number scan.next() scan.next scan if(number.equals("0")){
				break;
			} number.equals("0") number.equals number "0" {
				break;
			} break; int sum = 0; sum 0 for(int i = 0; i < number.length(); i++){
				char ch = number.charAt(i);
				String c = String.valueOf(ch);
				int n = Integer.parseInt(c);
				sum += n;
			} int i = 0; int i = 0; i 0 i < number.length() i number.length() number.length number i++ i++ i {
				char ch = number.charAt(i);
				String c = String.valueOf(ch);
				int n = Integer.parseInt(c);
				sum += n;
			} {
				char ch = number.charAt(i);
				String c = String.valueOf(ch);
				int n = Integer.parseInt(c);
				sum += n;
			} char ch = number.charAt(i); ch number.charAt(i) number.charAt number i String c = String.valueOf(ch); c String.valueOf(ch) String.valueOf String ch int n = Integer.parseInt(c); n Integer.parseInt(c) Integer.parseInt Integer c sum += n sum n list.add(sum) list.add list sum for(int n : list){
			System.out.println(n);
		} int n list {
			System.out.println(n);
		} {
			System.out.println(n);
		} System.out.println(n) System.out.println System.out System System.out n String[] args args public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<Integer> list = new ArrayList<Integer>();
		for(;;){
			String number = scan.next();
			if(number.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < number.length(); i++){
				char ch = number.charAt(i);
				String c = String.valueOf(ch);
				int n = Integer.parseInt(c);
				sum += n;
			}
			list.add(sum);
		}

		for(int n : list){
			System.out.println(n);
		}
	}
} public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<Integer> list = new ArrayList<Integer>();
		for(;;){
			String number = scan.next();
			if(number.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < number.length(); i++){
				char ch = number.charAt(i);
				String c = String.valueOf(ch);
				int n = Integer.parseInt(c);
				sum += n;
			}
			list.add(sum);
		}

		for(int n : list){
			System.out.println(n);
		}
	}
} Main
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<Integer> list = new ArrayList<Integer>();
		for(;;){
			String number = scan.next();
			if(number.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < number.length(); i++){
				char ch = number.charAt(i);
				String c = String.valueOf(ch);
				int n = Integer.parseInt(c);
				sum += n;
			}
			list.add(sum);
		}

		for(int n : list){
			System.out.println(n);
		}
	}
}