import java.util.*;

class Main {
	public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		final String lb = System.getProperty("line.separator");
		while(true){
			char[] num = sc.nextLine().toCharArray();
			int sum = 0;
			if(num[0] == '0') break;
			for(int i = 0; i < num.length; i++){
				sum += Integer.parseInt(String.valueOf(num[i]));
			}
			sb.append(sum).append(lb);	
		}
		System.out.print(sb.toString());
	}
} import java.util.*; util.* java class Main {
	public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		final String lb = System.getProperty("line.separator");
		while(true){
			char[] num = sc.nextLine().toCharArray();
			int sum = 0;
			if(num[0] == '0') break;
			for(int i = 0; i < num.length; i++){
				sum += Integer.parseInt(String.valueOf(num[i]));
			}
			sb.append(sum).append(lb);	
		}
		System.out.print(sb.toString());
	}
} Main public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		final String lb = System.getProperty("line.separator");
		while(true){
			char[] num = sc.nextLine().toCharArray();
			int sum = 0;
			if(num[0] == '0') break;
			for(int i = 0; i < num.length; i++){
				sum += Integer.parseInt(String.valueOf(num[i]));
			}
			sb.append(sum).append(lb);	
		}
		System.out.print(sb.toString());
	} main {
		final Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		final String lb = System.getProperty("line.separator");
		while(true){
			char[] num = sc.nextLine().toCharArray();
			int sum = 0;
			if(num[0] == '0') break;
			for(int i = 0; i < num.length; i++){
				sum += Integer.parseInt(String.valueOf(num[i]));
			}
			sb.append(sum).append(lb);	
		}
		System.out.print(sb.toString());
	} final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() final String lb = System.getProperty("line.separator"); lb System.getProperty("line.separator") System.getProperty System "line.separator" while(true){
			char[] num = sc.nextLine().toCharArray();
			int sum = 0;
			if(num[0] == '0') break;
			for(int i = 0; i < num.length; i++){
				sum += Integer.parseInt(String.valueOf(num[i]));
			}
			sb.append(sum).append(lb);	
		} true {
			char[] num = sc.nextLine().toCharArray();
			int sum = 0;
			if(num[0] == '0') break;
			for(int i = 0; i < num.length; i++){
				sum += Integer.parseInt(String.valueOf(num[i]));
			}
			sb.append(sum).append(lb);	
		} char[] num = sc.nextLine().toCharArray(); num sc.nextLine().toCharArray() sc.nextLine().toCharArray sc.nextLine() sc.nextLine sc int sum = 0; sum 0 if(num[0] == '0') break; num[0] == '0' num[0] num 0 '0' break; for(int i = 0; i < num.length; i++){
				sum += Integer.parseInt(String.valueOf(num[i]));
			} int i = 0; int i = 0; i 0 i < num.length i num.length num num.length i++ i++ i {
				sum += Integer.parseInt(String.valueOf(num[i]));
			} {
				sum += Integer.parseInt(String.valueOf(num[i]));
			} sum += Integer.parseInt(String.valueOf(num[i])) sum Integer.parseInt(String.valueOf(num[i])) Integer.parseInt Integer String.valueOf(num[i]) String.valueOf String num[i] num i sb.append(sum).append(lb) sb.append(sum).append sb.append(sum) sb.append sb sum lb System.out.print(sb.toString()) System.out.print System.out System System.out sb.toString() sb.toString sb String[] args args
import java.util.*;

class Main {
	public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		final String lb = System.getProperty("line.separator");
		while(true){
			char[] num = sc.nextLine().toCharArray();
			int sum = 0;
			if(num[0] == '0') break;
			for(int i = 0; i < num.length; i++){
				sum += Integer.parseInt(String.valueOf(num[i]));
			}
			sb.append(sum).append(lb);	
		}
		System.out.print(sb.toString());
	}
}