import java.util.*;
public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
    	int i, j;
    	while(true) {
        	String moji = sc.nextLine();
    		int sum = 0;
    		if(moji.equals("0")) break;
    	
    		for(char c : moji.toCharArray()) {
    			sum += Integer.parseInt(String.valueOf(c));
    		}
    		System.out.println(sum);
    	}
    }
} import java.util.*; util.* java public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
    	int i, j;
    	while(true) {
        	String moji = sc.nextLine();
    		int sum = 0;
    		if(moji.equals("0")) break;
    	
    		for(char c : moji.toCharArray()) {
    			sum += Integer.parseInt(String.valueOf(c));
    		}
    		System.out.println(sum);
    	}
    }
} Main public static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) throws Exception {
    	int i, j;
    	while(true) {
        	String moji = sc.nextLine();
    		int sum = 0;
    		if(moji.equals("0")) break;
    	
    		for(char c : moji.toCharArray()) {
    			sum += Integer.parseInt(String.valueOf(c));
    		}
    		System.out.println(sum);
    	}
    } main {
    	int i, j;
    	while(true) {
        	String moji = sc.nextLine();
    		int sum = 0;
    		if(moji.equals("0")) break;
    	
    		for(char c : moji.toCharArray()) {
    			sum += Integer.parseInt(String.valueOf(c));
    		}
    		System.out.println(sum);
    	}
    } int i i j; j while(true) {
        	String moji = sc.nextLine();
    		int sum = 0;
    		if(moji.equals("0")) break;
    	
    		for(char c : moji.toCharArray()) {
    			sum += Integer.parseInt(String.valueOf(c));
    		}
    		System.out.println(sum);
    	} true {
        	String moji = sc.nextLine();
    		int sum = 0;
    		if(moji.equals("0")) break;
    	
    		for(char c : moji.toCharArray()) {
    			sum += Integer.parseInt(String.valueOf(c));
    		}
    		System.out.println(sum);
    	} String moji = sc.nextLine(); moji sc.nextLine() sc.nextLine sc int sum = 0; sum 0 if(moji.equals("0")) break; moji.equals("0") moji.equals moji "0" break; for(char c : moji.toCharArray()) {
    			sum += Integer.parseInt(String.valueOf(c));
    		} char c moji.toCharArray() moji.toCharArray moji {
    			sum += Integer.parseInt(String.valueOf(c));
    		} {
    			sum += Integer.parseInt(String.valueOf(c));
    		} sum += Integer.parseInt(String.valueOf(c)) sum Integer.parseInt(String.valueOf(c)) Integer.parseInt Integer String.valueOf(c) String.valueOf String c System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
    	int i, j;
    	while(true) {
        	String moji = sc.nextLine();
    		int sum = 0;
    		if(moji.equals("0")) break;
    	
    		for(char c : moji.toCharArray()) {
    			sum += Integer.parseInt(String.valueOf(c));
    		}
    		System.out.println(sum);
    	}
    }
} public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
    	int i, j;
    	while(true) {
        	String moji = sc.nextLine();
    		int sum = 0;
    		if(moji.equals("0")) break;
    	
    		for(char c : moji.toCharArray()) {
    			sum += Integer.parseInt(String.valueOf(c));
    		}
    		System.out.println(sum);
    	}
    }
} Main
import java.util.*;
public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
    	int i, j;
    	while(true) {
        	String moji = sc.nextLine();
    		int sum = 0;
    		if(moji.equals("0")) break;
    	
    		for(char c : moji.toCharArray()) {
    			sum += Integer.parseInt(String.valueOf(c));
    		}
    		System.out.println(sum);
    	}
    }
}
