import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String dat;
		dat=br.readLine();
		
		do{
			int i=0;
			int g=0;
			do{
				g += Integer.parseInt(dat.substring(i,i+1));
				i++;
			} while(i<dat.length());
			System.out.println(g);
			dat=br.readLine();
		}while(dat.equals("0")==false);
		
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String dat;
		dat=br.readLine();
		
		do{
			int i=0;
			int g=0;
			do{
				g += Integer.parseInt(dat.substring(i,i+1));
				i++;
			} while(i<dat.length());
			System.out.println(g);
			dat=br.readLine();
		}while(dat.equals("0")==false);
		
	}

} Main public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String dat;
		dat=br.readLine();
		
		do{
			int i=0;
			int g=0;
			do{
				g += Integer.parseInt(dat.substring(i,i+1));
				i++;
			} while(i<dat.length());
			System.out.println(g);
			dat=br.readLine();
		}while(dat.equals("0")==false);
		
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String dat;
		dat=br.readLine();
		
		do{
			int i=0;
			int g=0;
			do{
				g += Integer.parseInt(dat.substring(i,i+1));
				i++;
			} while(i<dat.length());
			System.out.println(g);
			dat=br.readLine();
		}while(dat.equals("0")==false);
		
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String dat; dat dat=br.readLine() dat br.readLine() br.readLine br do{
			int i=0;
			int g=0;
			do{
				g += Integer.parseInt(dat.substring(i,i+1));
				i++;
			} while(i<dat.length());
			System.out.println(g);
			dat=br.readLine();
		}while(dat.equals("0")==false); dat.equals("0")==false dat.equals("0") dat.equals dat "0" false {
			int i=0;
			int g=0;
			do{
				g += Integer.parseInt(dat.substring(i,i+1));
				i++;
			} while(i<dat.length());
			System.out.println(g);
			dat=br.readLine();
		} int i=0; i 0 int g=0; g 0 do{
				g += Integer.parseInt(dat.substring(i,i+1));
				i++;
			} while(i<dat.length()); i<dat.length() i dat.length() dat.length dat {
				g += Integer.parseInt(dat.substring(i,i+1));
				i++;
			} g += Integer.parseInt(dat.substring(i,i+1)) g Integer.parseInt(dat.substring(i,i+1)) Integer.parseInt Integer dat.substring(i,i+1) dat.substring dat i i+1 i 1 i++ i System.out.println(g) System.out.println System.out System System.out g dat=br.readLine() dat br.readLine() br.readLine br String[] args args public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String dat;
		dat=br.readLine();
		
		do{
			int i=0;
			int g=0;
			do{
				g += Integer.parseInt(dat.substring(i,i+1));
				i++;
			} while(i<dat.length());
			System.out.println(g);
			dat=br.readLine();
		}while(dat.equals("0")==false);
		
	}

} public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String dat;
		dat=br.readLine();
		
		do{
			int i=0;
			int g=0;
			do{
				g += Integer.parseInt(dat.substring(i,i+1));
				i++;
			} while(i<dat.length());
			System.out.println(g);
			dat=br.readLine();
		}while(dat.equals("0")==false);
		
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String dat;
		dat=br.readLine();
		
		do{
			int i=0;
			int g=0;
			do{
				g += Integer.parseInt(dat.substring(i,i+1));
				i++;
			} while(i<dat.length());
			System.out.println(g);
			dat=br.readLine();
		}while(dat.equals("0")==false);
		
	}

}