import java.io.*;
import java.util.Scanner;
import java.lang.*;

class Main{
	public static void main(String[] args){
		try{
			Scanner stdIn = new Scanner(System.in);
			while(true){
				String s = stdIn.nextLine();
				
				int l = s.length();
				int k = 0;
				for(int i = 0;i < l;i++){
					char a = s.charAt(i);
					int a2 = Character.getNumericValue(a);
					k += a2;
				}
				if(k == 0) break;
				System.out.print(k);
				System.out.println();
			}
		} catch(Exception e){
		}
	}
}			 import java.io.*; io.* java import java.util.Scanner; Scanner java.util import java.lang.*; lang.* java class Main{
	public static void main(String[] args){
		try{
			Scanner stdIn = new Scanner(System.in);
			while(true){
				String s = stdIn.nextLine();
				
				int l = s.length();
				int k = 0;
				for(int i = 0;i < l;i++){
					char a = s.charAt(i);
					int a2 = Character.getNumericValue(a);
					k += a2;
				}
				if(k == 0) break;
				System.out.print(k);
				System.out.println();
			}
		} catch(Exception e){
		}
	}
} Main public static void main(String[] args){
		try{
			Scanner stdIn = new Scanner(System.in);
			while(true){
				String s = stdIn.nextLine();
				
				int l = s.length();
				int k = 0;
				for(int i = 0;i < l;i++){
					char a = s.charAt(i);
					int a2 = Character.getNumericValue(a);
					k += a2;
				}
				if(k == 0) break;
				System.out.print(k);
				System.out.println();
			}
		} catch(Exception e){
		}
	} main {
		try{
			Scanner stdIn = new Scanner(System.in);
			while(true){
				String s = stdIn.nextLine();
				
				int l = s.length();
				int k = 0;
				for(int i = 0;i < l;i++){
					char a = s.charAt(i);
					int a2 = Character.getNumericValue(a);
					k += a2;
				}
				if(k == 0) break;
				System.out.print(k);
				System.out.println();
			}
		} catch(Exception e){
		}
	} try{
			Scanner stdIn = new Scanner(System.in);
			while(true){
				String s = stdIn.nextLine();
				
				int l = s.length();
				int k = 0;
				for(int i = 0;i < l;i++){
					char a = s.charAt(i);
					int a2 = Character.getNumericValue(a);
					k += a2;
				}
				if(k == 0) break;
				System.out.print(k);
				System.out.println();
			}
		} catch(Exception e){
		} catch(Exception e){
		} Exception e {
		} {
			Scanner stdIn = new Scanner(System.in);
			while(true){
				String s = stdIn.nextLine();
				
				int l = s.length();
				int k = 0;
				for(int i = 0;i < l;i++){
					char a = s.charAt(i);
					int a2 = Character.getNumericValue(a);
					k += a2;
				}
				if(k == 0) break;
				System.out.print(k);
				System.out.println();
			}
		} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) while(true){
				String s = stdIn.nextLine();
				
				int l = s.length();
				int k = 0;
				for(int i = 0;i < l;i++){
					char a = s.charAt(i);
					int a2 = Character.getNumericValue(a);
					k += a2;
				}
				if(k == 0) break;
				System.out.print(k);
				System.out.println();
			} true {
				String s = stdIn.nextLine();
				
				int l = s.length();
				int k = 0;
				for(int i = 0;i < l;i++){
					char a = s.charAt(i);
					int a2 = Character.getNumericValue(a);
					k += a2;
				}
				if(k == 0) break;
				System.out.print(k);
				System.out.println();
			} String s = stdIn.nextLine(); s stdIn.nextLine() stdIn.nextLine stdIn int l = s.length(); l s.length() s.length s int k = 0; k 0 for(int i = 0;i < l;i++){
					char a = s.charAt(i);
					int a2 = Character.getNumericValue(a);
					k += a2;
				} int i = 0; int i = 0; i 0 i < l i l i++ i++ i {
					char a = s.charAt(i);
					int a2 = Character.getNumericValue(a);
					k += a2;
				} {
					char a = s.charAt(i);
					int a2 = Character.getNumericValue(a);
					k += a2;
				} char a = s.charAt(i); a s.charAt(i) s.charAt s i int a2 = Character.getNumericValue(a); a2 Character.getNumericValue(a) Character.getNumericValue Character a k += a2 k a2 if(k == 0) break; k == 0 k 0 break; System.out.print(k) System.out.print System.out System System.out k System.out.println() System.out.println System.out System System.out String[] args args
import java.io.*;
import java.util.Scanner;
import java.lang.*;

class Main{
	public static void main(String[] args){
		try{
			Scanner stdIn = new Scanner(System.in);
			while(true){
				String s = stdIn.nextLine();
				
				int l = s.length();
				int k = 0;
				for(int i = 0;i < l;i++){
					char a = s.charAt(i);
					int a2 = Character.getNumericValue(a);
					k += a2;
				}
				if(k == 0) break;
				System.out.print(k);
				System.out.println();
			}
		} catch(Exception e){
		}
	}
}			