import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String tmp = sc.next();
			if(tmp.equals("0")) break;
			int sum = 0;
			char[] c = tmp.toCharArray();
			for(int i = 0; i < c.length; i++){
				sum += c[i]-'0';
			}
			System.out.println(sum);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String tmp = sc.next();
			if(tmp.equals("0")) break;
			int sum = 0;
			char[] c = tmp.toCharArray();
			for(int i = 0; i < c.length; i++){
				sum += c[i]-'0';
			}
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String tmp = sc.next();
			if(tmp.equals("0")) break;
			int sum = 0;
			char[] c = tmp.toCharArray();
			for(int i = 0; i < c.length; i++){
				sum += c[i]-'0';
			}
			System.out.println(sum);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String tmp = sc.next();
			if(tmp.equals("0")) break;
			int sum = 0;
			char[] c = tmp.toCharArray();
			for(int i = 0; i < c.length; i++){
				sum += c[i]-'0';
			}
			System.out.println(sum);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(sc.hasNext()){
			String tmp = sc.next();
			if(tmp.equals("0")) break;
			int sum = 0;
			char[] c = tmp.toCharArray();
			for(int i = 0; i < c.length; i++){
				sum += c[i]-'0';
			}
			System.out.println(sum);
		} sc.hasNext() sc.hasNext sc {
			String tmp = sc.next();
			if(tmp.equals("0")) break;
			int sum = 0;
			char[] c = tmp.toCharArray();
			for(int i = 0; i < c.length; i++){
				sum += c[i]-'0';
			}
			System.out.println(sum);
		} String tmp = sc.next(); tmp sc.next() sc.next sc if(tmp.equals("0")) break; tmp.equals("0") tmp.equals tmp "0" break; int sum = 0; sum 0 char[] c = tmp.toCharArray(); c tmp.toCharArray() tmp.toCharArray tmp for(int i = 0; i < c.length; i++){
				sum += c[i]-'0';
			} int i = 0; int i = 0; i 0 i < c.length i c.length c c.length i++ i++ i {
				sum += c[i]-'0';
			} {
				sum += c[i]-'0';
			} sum += c[i]-'0' sum c[i]-'0' c[i] c i '0' System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String tmp = sc.next();
			if(tmp.equals("0")) break;
			int sum = 0;
			char[] c = tmp.toCharArray();
			for(int i = 0; i < c.length; i++){
				sum += c[i]-'0';
			}
			System.out.println(sum);
		}
	}
} public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String tmp = sc.next();
			if(tmp.equals("0")) break;
			int sum = 0;
			char[] c = tmp.toCharArray();
			for(int i = 0; i < c.length; i++){
				sum += c[i]-'0';
			}
			System.out.println(sum);
		}
	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String tmp = sc.next();
			if(tmp.equals("0")) break;
			int sum = 0;
			char[] c = tmp.toCharArray();
			for(int i = 0; i < c.length; i++){
				sum += c[i]-'0';
			}
			System.out.println(sum);
		}
	}
}