import java.util.Scanner;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<String> before = new ArrayList<String>();
		String x;
		int sum = 0;
		while (true) {
			x = sc.next();
			if (x.equals("0")) {
				break;
			}
			before.add(x);
		}
		char[] c;
		for (int i = 0; i < before.size(); i++) {
			c = (before.get(i)).toCharArray();
			for (int j = 0; j < c.length; j++) {
				sum += (c[j] - '0');
			}
			System.out.println(sum);
			sum = 0;
		}
		sc.close();
	}
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<String> before = new ArrayList<String>();
		String x;
		int sum = 0;
		while (true) {
			x = sc.next();
			if (x.equals("0")) {
				break;
			}
			before.add(x);
		}
		char[] c;
		for (int i = 0; i < before.size(); i++) {
			c = (before.get(i)).toCharArray();
			for (int j = 0; j < c.length; j++) {
				sum += (c[j] - '0');
			}
			System.out.println(sum);
			sum = 0;
		}
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<String> before = new ArrayList<String>();
		String x;
		int sum = 0;
		while (true) {
			x = sc.next();
			if (x.equals("0")) {
				break;
			}
			before.add(x);
		}
		char[] c;
		for (int i = 0; i < before.size(); i++) {
			c = (before.get(i)).toCharArray();
			for (int j = 0; j < c.length; j++) {
				sum += (c[j] - '0');
			}
			System.out.println(sum);
			sum = 0;
		}
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		ArrayList<String> before = new ArrayList<String>();
		String x;
		int sum = 0;
		while (true) {
			x = sc.next();
			if (x.equals("0")) {
				break;
			}
			before.add(x);
		}
		char[] c;
		for (int i = 0; i < before.size(); i++) {
			c = (before.get(i)).toCharArray();
			for (int j = 0; j < c.length; j++) {
				sum += (c[j] - '0');
			}
			System.out.println(sum);
			sum = 0;
		}
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) ArrayList<String> before = new ArrayList<String>(); before new ArrayList<String>() String x; x int sum = 0; sum 0 while (true) {
			x = sc.next();
			if (x.equals("0")) {
				break;
			}
			before.add(x);
		} true {
			x = sc.next();
			if (x.equals("0")) {
				break;
			}
			before.add(x);
		} x = sc.next() x sc.next() sc.next sc if (x.equals("0")) {
				break;
			} x.equals("0") x.equals x "0" {
				break;
			} break; before.add(x) before.add before x char[] c; c for (int i = 0; i < before.size(); i++) {
			c = (before.get(i)).toCharArray();
			for (int j = 0; j < c.length; j++) {
				sum += (c[j] - '0');
			}
			System.out.println(sum);
			sum = 0;
		} int i = 0; int i = 0; i 0 i < before.size() i before.size() before.size before i++ i++ i {
			c = (before.get(i)).toCharArray();
			for (int j = 0; j < c.length; j++) {
				sum += (c[j] - '0');
			}
			System.out.println(sum);
			sum = 0;
		} {
			c = (before.get(i)).toCharArray();
			for (int j = 0; j < c.length; j++) {
				sum += (c[j] - '0');
			}
			System.out.println(sum);
			sum = 0;
		} c = (before.get(i)).toCharArray() c (before.get(i)).toCharArray() (before.get(i)).toCharArray (before.get(i)) before.get before i for (int j = 0; j < c.length; j++) {
				sum += (c[j] - '0');
			} int j = 0; int j = 0; j 0 j < c.length j c.length c c.length j++ j++ j {
				sum += (c[j] - '0');
			} {
				sum += (c[j] - '0');
			} sum += (c[j] - '0') sum (c[j] - '0') c[j] c j '0' System.out.println(sum) System.out.println System.out System System.out sum sum = 0 sum 0 sc.close() sc.close sc String[] args args public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<String> before = new ArrayList<String>();
		String x;
		int sum = 0;
		while (true) {
			x = sc.next();
			if (x.equals("0")) {
				break;
			}
			before.add(x);
		}
		char[] c;
		for (int i = 0; i < before.size(); i++) {
			c = (before.get(i)).toCharArray();
			for (int j = 0; j < c.length; j++) {
				sum += (c[j] - '0');
			}
			System.out.println(sum);
			sum = 0;
		}
		sc.close();
	}
} public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<String> before = new ArrayList<String>();
		String x;
		int sum = 0;
		while (true) {
			x = sc.next();
			if (x.equals("0")) {
				break;
			}
			before.add(x);
		}
		char[] c;
		for (int i = 0; i < before.size(); i++) {
			c = (before.get(i)).toCharArray();
			for (int j = 0; j < c.length; j++) {
				sum += (c[j] - '0');
			}
			System.out.println(sum);
			sum = 0;
		}
		sc.close();
	}
} Main
import java.util.Scanner;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<String> before = new ArrayList<String>();
		String x;
		int sum = 0;
		while (true) {
			x = sc.next();
			if (x.equals("0")) {
				break;
			}
			before.add(x);
		}
		char[] c;
		for (int i = 0; i < before.size(); i++) {
			c = (before.get(i)).toCharArray();
			for (int j = 0; j < c.length; j++) {
				sum += (c[j] - '0');
			}
			System.out.println(sum);
			sum = 0;
		}
		sc.close();
	}
}
