import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String input = br.readLine();
        	if (input.equals("0"))
        		break;
        	int sum = 0;
        	for (int i = 0; i < input.length(); i++)
        	{
        		String a = String.valueOf(input.charAt(i));
        		sum += Integer.parseInt(a);
        	}
        	System.out.println(sum);
        	
        }
    	
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String input = br.readLine();
        	if (input.equals("0"))
        		break;
        	int sum = 0;
        	for (int i = 0; i < input.length(); i++)
        	{
        		String a = String.valueOf(input.charAt(i));
        		sum += Integer.parseInt(a);
        	}
        	System.out.println(sum);
        	
        }
    	
	}

} Main public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String input = br.readLine();
        	if (input.equals("0"))
        		break;
        	int sum = 0;
        	for (int i = 0; i < input.length(); i++)
        	{
        		String a = String.valueOf(input.charAt(i));
        		sum += Integer.parseInt(a);
        	}
        	System.out.println(sum);
        	
        }
    	
	} main {
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String input = br.readLine();
        	if (input.equals("0"))
        		break;
        	int sum = 0;
        	for (int i = 0; i < input.length(); i++)
        	{
        		String a = String.valueOf(input.charAt(i));
        		sum += Integer.parseInt(a);
        	}
        	System.out.println(sum);
        	
        }
    	
	} InputStreamReader isr = new InputStreamReader(System.in); isr new InputStreamReader(System.in) BufferedReader br = new BufferedReader(isr); br new BufferedReader(isr) while (true)
        {
        	String input = br.readLine();
        	if (input.equals("0"))
        		break;
        	int sum = 0;
        	for (int i = 0; i < input.length(); i++)
        	{
        		String a = String.valueOf(input.charAt(i));
        		sum += Integer.parseInt(a);
        	}
        	System.out.println(sum);
        	
        } true {
        	String input = br.readLine();
        	if (input.equals("0"))
        		break;
        	int sum = 0;
        	for (int i = 0; i < input.length(); i++)
        	{
        		String a = String.valueOf(input.charAt(i));
        		sum += Integer.parseInt(a);
        	}
        	System.out.println(sum);
        	
        } String input = br.readLine(); input br.readLine() br.readLine br if (input.equals("0"))
        		break; input.equals("0") input.equals input "0" break; int sum = 0; sum 0 for (int i = 0; i < input.length(); i++)
        	{
        		String a = String.valueOf(input.charAt(i));
        		sum += Integer.parseInt(a);
        	} int i = 0; int i = 0; i 0 i < input.length() i input.length() input.length input i++ i++ i {
        		String a = String.valueOf(input.charAt(i));
        		sum += Integer.parseInt(a);
        	} {
        		String a = String.valueOf(input.charAt(i));
        		sum += Integer.parseInt(a);
        	} String a = String.valueOf(input.charAt(i)); a String.valueOf(input.charAt(i)) String.valueOf String input.charAt(i) input.charAt input i sum += Integer.parseInt(a) sum Integer.parseInt(a) Integer.parseInt Integer a System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String input = br.readLine();
        	if (input.equals("0"))
        		break;
        	int sum = 0;
        	for (int i = 0; i < input.length(); i++)
        	{
        		String a = String.valueOf(input.charAt(i));
        		sum += Integer.parseInt(a);
        	}
        	System.out.println(sum);
        	
        }
    	
	}

} public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String input = br.readLine();
        	if (input.equals("0"))
        		break;
        	int sum = 0;
        	for (int i = 0; i < input.length(); i++)
        	{
        		String a = String.valueOf(input.charAt(i));
        		sum += Integer.parseInt(a);
        	}
        	System.out.println(sum);
        	
        }
    	
	}

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String input = br.readLine();
        	if (input.equals("0"))
        		break;
        	int sum = 0;
        	for (int i = 0; i < input.length(); i++)
        	{
        		String a = String.valueOf(input.charAt(i));
        		sum += Integer.parseInt(a);
        	}
        	System.out.println(sum);
        	
        }
    	
	}

}