import java.io.*;

class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		//StringBuilder sb = new StringBuilder();
		String str;
		char[] c;
		int sum;
		while((str = buf.readLine()) != null){
			if(str.equals("0"))
				break;
			sum = 0;
			c = str.toCharArray();
			for(int i=0; i<c.length ; i++){
				sum += Integer.parseInt(Character.toString(c[i]));
			}
			System.out.println(sum);
		}

	}
} import java.io.*; io.* java class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		//StringBuilder sb = new StringBuilder();
		String str;
		char[] c;
		int sum;
		while((str = buf.readLine()) != null){
			if(str.equals("0"))
				break;
			sum = 0;
			c = str.toCharArray();
			for(int i=0; i<c.length ; i++){
				sum += Integer.parseInt(Character.toString(c[i]));
			}
			System.out.println(sum);
		}

	}
} Main public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		//StringBuilder sb = new StringBuilder();
		String str;
		char[] c;
		int sum;
		while((str = buf.readLine()) != null){
			if(str.equals("0"))
				break;
			sum = 0;
			c = str.toCharArray();
			for(int i=0; i<c.length ; i++){
				sum += Integer.parseInt(Character.toString(c[i]));
			}
			System.out.println(sum);
		}

	} main {
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		//StringBuilder sb = new StringBuilder();
		String str;
		char[] c;
		int sum;
		while((str = buf.readLine()) != null){
			if(str.equals("0"))
				break;
			sum = 0;
			c = str.toCharArray();
			for(int i=0; i<c.length ; i++){
				sum += Integer.parseInt(Character.toString(c[i]));
			}
			System.out.println(sum);
		}

	} BufferedReader buf = new BufferedReader(new InputStreamReader(System.in)); buf new BufferedReader(new InputStreamReader(System.in)) String str; str char[] c; c int sum; sum while((str = buf.readLine()) != null){
			if(str.equals("0"))
				break;
			sum = 0;
			c = str.toCharArray();
			for(int i=0; i<c.length ; i++){
				sum += Integer.parseInt(Character.toString(c[i]));
			}
			System.out.println(sum);
		} (str = buf.readLine()) != null (str = buf.readLine()) str buf.readLine() buf.readLine buf null {
			if(str.equals("0"))
				break;
			sum = 0;
			c = str.toCharArray();
			for(int i=0; i<c.length ; i++){
				sum += Integer.parseInt(Character.toString(c[i]));
			}
			System.out.println(sum);
		} if(str.equals("0"))
				break; str.equals("0") str.equals str "0" break; sum = 0 sum 0 c = str.toCharArray() c str.toCharArray() str.toCharArray str for(int i=0; i<c.length ; i++){
				sum += Integer.parseInt(Character.toString(c[i]));
			} int i=0; int i=0; i 0 i<c.length i c.length c c.length i++ i++ i {
				sum += Integer.parseInt(Character.toString(c[i]));
			} {
				sum += Integer.parseInt(Character.toString(c[i]));
			} sum += Integer.parseInt(Character.toString(c[i])) sum Integer.parseInt(Character.toString(c[i])) Integer.parseInt Integer Character.toString(c[i]) Character.toString Character c[i] c i System.out.println(sum) System.out.println System.out System System.out sum String args[] args
import java.io.*;

class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		//StringBuilder sb = new StringBuilder();
		String str;
		char[] c;
		int sum;
		while((str = buf.readLine()) != null){
			if(str.equals("0"))
				break;
			sum = 0;
			c = str.toCharArray();
			for(int i=0; i<c.length ; i++){
				sum += Integer.parseInt(Character.toString(c[i]));
			}
			System.out.println(sum);
		}

	}
}