import java.util.Scanner;

//20180510
//04

public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			char[] cha = str.toCharArray();
			int sum = 0;

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

			for(int i = 0;i < cha.length;i++) {

				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		}

		scanner.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			char[] cha = str.toCharArray();
			int sum = 0;

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

			for(int i = 0;i < cha.length;i++) {

				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		}

		scanner.close();
    }
} Main public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			char[] cha = str.toCharArray();
			int sum = 0;

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

			for(int i = 0;i < cha.length;i++) {

				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		}

		scanner.close();
    } main {
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			char[] cha = str.toCharArray();
			int sum = 0;

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

			for(int i = 0;i < cha.length;i++) {

				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		}

		scanner.close();
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while (scanner.hasNext()) {
			String str = scanner.nextLine();
			char[] cha = str.toCharArray();
			int sum = 0;

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

			for(int i = 0;i < cha.length;i++) {

				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		} scanner.hasNext() scanner.hasNext scanner {
			String str = scanner.nextLine();
			char[] cha = str.toCharArray();
			int sum = 0;

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

			for(int i = 0;i < cha.length;i++) {

				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		} String str = scanner.nextLine(); str scanner.nextLine() scanner.nextLine scanner char[] cha = str.toCharArray(); cha str.toCharArray() str.toCharArray str int sum = 0; sum 0 if(str.equals("0")) {
				break;
			} str.equals("0") str.equals str "0" {
				break;
			} break; for(int i = 0;i < cha.length;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 {

				sum += Character.getNumericValue(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 scanner.close() scanner.close scanner String[] args args public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			char[] cha = str.toCharArray();
			int sum = 0;

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

			for(int i = 0;i < cha.length;i++) {

				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		}

		scanner.close();
    }
} public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			char[] cha = str.toCharArray();
			int sum = 0;

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

			for(int i = 0;i < cha.length;i++) {

				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		}

		scanner.close();
    }
} Main
import java.util.Scanner;

//20180510
//04

public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			char[] cha = str.toCharArray();
			int sum = 0;

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

			for(int i = 0;i < cha.length;i++) {

				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		}

		scanner.close();
    }
}
