import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		while(true) {
			String x = sc.next();
			if(x.equals("0")) {
				break;
			}
			String[] line = x.split("");
			int[] tmp = new int[line.length];
			long count = 0;
			for(int i=0;i<line.length;i++) {
				tmp[i] = Integer.parseInt(line[i]);
				count+=tmp[i];
			}
			System.out.println(count);
		}
		sc.close();
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		while(true) {
			String x = sc.next();
			if(x.equals("0")) {
				break;
			}
			String[] line = x.split("");
			int[] tmp = new int[line.length];
			long count = 0;
			for(int i=0;i<line.length;i++) {
				tmp[i] = Integer.parseInt(line[i]);
				count+=tmp[i];
			}
			System.out.println(count);
		}
		sc.close();
	}
} Main public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		while(true) {
			String x = sc.next();
			if(x.equals("0")) {
				break;
			}
			String[] line = x.split("");
			int[] tmp = new int[line.length];
			long count = 0;
			for(int i=0;i<line.length;i++) {
				tmp[i] = Integer.parseInt(line[i]);
				count+=tmp[i];
			}
			System.out.println(count);
		}
		sc.close();
	} main {

		Scanner sc = new Scanner(System.in);

		while(true) {
			String x = sc.next();
			if(x.equals("0")) {
				break;
			}
			String[] line = x.split("");
			int[] tmp = new int[line.length];
			long count = 0;
			for(int i=0;i<line.length;i++) {
				tmp[i] = Integer.parseInt(line[i]);
				count+=tmp[i];
			}
			System.out.println(count);
		}
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true) {
			String x = sc.next();
			if(x.equals("0")) {
				break;
			}
			String[] line = x.split("");
			int[] tmp = new int[line.length];
			long count = 0;
			for(int i=0;i<line.length;i++) {
				tmp[i] = Integer.parseInt(line[i]);
				count+=tmp[i];
			}
			System.out.println(count);
		} true {
			String x = sc.next();
			if(x.equals("0")) {
				break;
			}
			String[] line = x.split("");
			int[] tmp = new int[line.length];
			long count = 0;
			for(int i=0;i<line.length;i++) {
				tmp[i] = Integer.parseInt(line[i]);
				count+=tmp[i];
			}
			System.out.println(count);
		} String x = sc.next(); x sc.next() sc.next sc if(x.equals("0")) {
				break;
			} x.equals("0") x.equals x "0" {
				break;
			} break; String[] line = x.split(""); line x.split("") x.split x "" int[] tmp = new int[line.length]; tmp new int[line.length] line.length line line.length long count = 0; count 0 for(int i=0;i<line.length;i++) {
				tmp[i] = Integer.parseInt(line[i]);
				count+=tmp[i];
			} int i=0; int i=0; i 0 i<line.length i line.length line line.length i++ i++ i {
				tmp[i] = Integer.parseInt(line[i]);
				count+=tmp[i];
			} {
				tmp[i] = Integer.parseInt(line[i]);
				count+=tmp[i];
			} tmp[i] = Integer.parseInt(line[i]) tmp[i] tmp i Integer.parseInt(line[i]) Integer.parseInt Integer line[i] line i count+=tmp[i] count tmp[i] tmp i System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		while(true) {
			String x = sc.next();
			if(x.equals("0")) {
				break;
			}
			String[] line = x.split("");
			int[] tmp = new int[line.length];
			long count = 0;
			for(int i=0;i<line.length;i++) {
				tmp[i] = Integer.parseInt(line[i]);
				count+=tmp[i];
			}
			System.out.println(count);
		}
		sc.close();
	}
} public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		while(true) {
			String x = sc.next();
			if(x.equals("0")) {
				break;
			}
			String[] line = x.split("");
			int[] tmp = new int[line.length];
			long count = 0;
			for(int i=0;i<line.length;i++) {
				tmp[i] = Integer.parseInt(line[i]);
				count+=tmp[i];
			}
			System.out.println(count);
		}
		sc.close();
	}
} Main
import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		while(true) {
			String x = sc.next();
			if(x.equals("0")) {
				break;
			}
			String[] line = x.split("");
			int[] tmp = new int[line.length];
			long count = 0;
			for(int i=0;i<line.length;i++) {
				tmp[i] = Integer.parseInt(line[i]);
				count+=tmp[i];
			}
			System.out.println(count);
		}
		sc.close();
	}
}
