import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			int sum = 0;
			String s = stdIn.nextLine();
			if(s.charAt(0) == '0')
				break;
			for (int i=0; i<s.length(); i++) {
				sum += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(sum);
		}
	}
} import java.util.*; util.* java import java.io.*; io.* java class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			int sum = 0;
			String s = stdIn.nextLine();
			if(s.charAt(0) == '0')
				break;
			for (int i=0; i<s.length(); i++) {
				sum += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			int sum = 0;
			String s = stdIn.nextLine();
			if(s.charAt(0) == '0')
				break;
			for (int i=0; i<s.length(); i++) {
				sum += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(sum);
		}
	} main {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			int sum = 0;
			String s = stdIn.nextLine();
			if(s.charAt(0) == '0')
				break;
			for (int i=0; i<s.length(); i++) {
				sum += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(sum);
		}
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) while (true) {
			int sum = 0;
			String s = stdIn.nextLine();
			if(s.charAt(0) == '0')
				break;
			for (int i=0; i<s.length(); i++) {
				sum += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(sum);
		} true {
			int sum = 0;
			String s = stdIn.nextLine();
			if(s.charAt(0) == '0')
				break;
			for (int i=0; i<s.length(); i++) {
				sum += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(sum);
		} int sum = 0; sum 0 String s = stdIn.nextLine(); s stdIn.nextLine() stdIn.nextLine stdIn if(s.charAt(0) == '0')
				break; s.charAt(0) == '0' s.charAt(0) s.charAt s 0 '0' break; for (int i=0; i<s.length(); i++) {
				sum += Integer.parseInt(""+s.charAt(i));
			} int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
				sum += Integer.parseInt(""+s.charAt(i));
			} {
				sum += Integer.parseInt(""+s.charAt(i));
			} sum += Integer.parseInt(""+s.charAt(i)) sum Integer.parseInt(""+s.charAt(i)) Integer.parseInt Integer ""+s.charAt(i) "" s.charAt(i) s.charAt s i System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			int sum = 0;
			String s = stdIn.nextLine();
			if(s.charAt(0) == '0')
				break;
			for (int i=0; i<s.length(); i++) {
				sum += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(sum);
		}
	}
}