import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int x = 0;
		while(true){
			String line = br.readLine();
			char[] c = line.toCharArray();
			for(int i = 0; i < c.length; i++){
				x += Integer.parseInt("" + c[i]);
			}
			if( x == 0){
				break;
			}else{
				sb.append(x+"\n");
				x = 0;
			}
		}
		System.out.print(sb);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int x = 0;
		while(true){
			String line = br.readLine();
			char[] c = line.toCharArray();
			for(int i = 0; i < c.length; i++){
				x += Integer.parseInt("" + c[i]);
			}
			if( x == 0){
				break;
			}else{
				sb.append(x+"\n");
				x = 0;
			}
		}
		System.out.print(sb);
	}
} Main public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int x = 0;
		while(true){
			String line = br.readLine();
			char[] c = line.toCharArray();
			for(int i = 0; i < c.length; i++){
				x += Integer.parseInt("" + c[i]);
			}
			if( x == 0){
				break;
			}else{
				sb.append(x+"\n");
				x = 0;
			}
		}
		System.out.print(sb);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int x = 0;
		while(true){
			String line = br.readLine();
			char[] c = line.toCharArray();
			for(int i = 0; i < c.length; i++){
				x += Integer.parseInt("" + c[i]);
			}
			if( x == 0){
				break;
			}else{
				sb.append(x+"\n");
				x = 0;
			}
		}
		System.out.print(sb);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() int x = 0; x 0 while(true){
			String line = br.readLine();
			char[] c = line.toCharArray();
			for(int i = 0; i < c.length; i++){
				x += Integer.parseInt("" + c[i]);
			}
			if( x == 0){
				break;
			}else{
				sb.append(x+"\n");
				x = 0;
			}
		} true {
			String line = br.readLine();
			char[] c = line.toCharArray();
			for(int i = 0; i < c.length; i++){
				x += Integer.parseInt("" + c[i]);
			}
			if( x == 0){
				break;
			}else{
				sb.append(x+"\n");
				x = 0;
			}
		} String line = br.readLine(); line br.readLine() br.readLine br char[] c = line.toCharArray(); c line.toCharArray() line.toCharArray line for(int i = 0; i < c.length; i++){
				x += Integer.parseInt("" + c[i]);
			} int i = 0; int i = 0; i 0 i < c.length i c.length c c.length i++ i++ i {
				x += Integer.parseInt("" + c[i]);
			} {
				x += Integer.parseInt("" + c[i]);
			} x += Integer.parseInt("" + c[i]) x Integer.parseInt("" + c[i]) Integer.parseInt Integer "" + c[i] "" c[i] c i if( x == 0){
				break;
			}else{
				sb.append(x+"\n");
				x = 0;
			} x == 0 x 0 {
				break;
			} break; {
				sb.append(x+"\n");
				x = 0;
			} sb.append(x+"\n") sb.append sb x+"\n" x "\n" x = 0 x 0 System.out.print(sb) System.out.print System.out System System.out sb String[] args args public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int x = 0;
		while(true){
			String line = br.readLine();
			char[] c = line.toCharArray();
			for(int i = 0; i < c.length; i++){
				x += Integer.parseInt("" + c[i]);
			}
			if( x == 0){
				break;
			}else{
				sb.append(x+"\n");
				x = 0;
			}
		}
		System.out.print(sb);
	}
} public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int x = 0;
		while(true){
			String line = br.readLine();
			char[] c = line.toCharArray();
			for(int i = 0; i < c.length; i++){
				x += Integer.parseInt("" + c[i]);
			}
			if( x == 0){
				break;
			}else{
				sb.append(x+"\n");
				x = 0;
			}
		}
		System.out.print(sb);
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int x = 0;
		while(true){
			String line = br.readLine();
			char[] c = line.toCharArray();
			for(int i = 0; i < c.length; i++){
				x += Integer.parseInt("" + c[i]);
			}
			if( x == 0){
				break;
			}else{
				sb.append(x+"\n");
				x = 0;
			}
		}
		System.out.print(sb);
	}
}