import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {
			String input = sc.next();
			if(input.equals("0")) break;
			int sum = 0;
			for(int i=0; i<input.length(); i++) {
				sum += Integer.parseInt(input.split("")[i]);
			}
			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 input = sc.next();
			if(input.equals("0")) break;
			int sum = 0;
			for(int i=0; i<input.length(); i++) {
				sum += Integer.parseInt(input.split("")[i]);
			}
			System.out.println(sum);
		}

		sc.close();

	}

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

		Scanner sc = new Scanner(System.in);

		while(true) {
			String input = sc.next();
			if(input.equals("0")) break;
			int sum = 0;
			for(int i=0; i<input.length(); i++) {
				sum += Integer.parseInt(input.split("")[i]);
			}
			System.out.println(sum);
		}

		sc.close();

	} main {

		Scanner sc = new Scanner(System.in);

		while(true) {
			String input = sc.next();
			if(input.equals("0")) break;
			int sum = 0;
			for(int i=0; i<input.length(); i++) {
				sum += Integer.parseInt(input.split("")[i]);
			}
			System.out.println(sum);
		}

		sc.close();

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true) {
			String input = sc.next();
			if(input.equals("0")) break;
			int sum = 0;
			for(int i=0; i<input.length(); i++) {
				sum += Integer.parseInt(input.split("")[i]);
			}
			System.out.println(sum);
		} true {
			String input = sc.next();
			if(input.equals("0")) break;
			int sum = 0;
			for(int i=0; i<input.length(); i++) {
				sum += Integer.parseInt(input.split("")[i]);
			}
			System.out.println(sum);
		} String input = sc.next(); input sc.next() sc.next sc if(input.equals("0")) break; input.equals("0") input.equals input "0" break; int sum = 0; sum 0 for(int i=0; i<input.length(); i++) {
				sum += Integer.parseInt(input.split("")[i]);
			} int i=0; int i=0; i 0 i<input.length() i input.length() input.length input i++ i++ i {
				sum += Integer.parseInt(input.split("")[i]);
			} {
				sum += Integer.parseInt(input.split("")[i]);
			} sum += Integer.parseInt(input.split("")[i]) sum Integer.parseInt(input.split("")[i]) Integer.parseInt Integer input.split("")[i] input.split("") input.split input "" i 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 input = sc.next();
			if(input.equals("0")) break;
			int sum = 0;
			for(int i=0; i<input.length(); i++) {
				sum += Integer.parseInt(input.split("")[i]);
			}
			System.out.println(sum);
		}

		sc.close();

	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {
			String input = sc.next();
			if(input.equals("0")) break;
			int sum = 0;
			for(int i=0; i<input.length(); i++) {
				sum += Integer.parseInt(input.split("")[i]);
			}
			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 input = sc.next();
			if(input.equals("0")) break;
			int sum = 0;
			for(int i=0; i<input.length(); i++) {
				sum += Integer.parseInt(input.split("")[i]);
			}
			System.out.println(sum);
		}

		sc.close();

	}

}

