import java.util.Scanner;

public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(;;)
		{
			String in = scanner.next();
			//String out = "";
			if(in.equals("0"))
			{
				break;
			}
			
			int sum = 0;
			for(int i=0; i<in.length(); i++)
			{
				char c = in.charAt(i);
				sum += c - '0';
			}
			
			System.out.println(sum+"");
		}
	}
} import java.util.Scanner; Scanner java.util public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(;;)
		{
			String in = scanner.next();
			//String out = "";
			if(in.equals("0"))
			{
				break;
			}
			
			int sum = 0;
			for(int i=0; i<in.length(); i++)
			{
				char c = in.charAt(i);
				sum += c - '0';
			}
			
			System.out.println(sum+"");
		}
	}
} Main public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(;;)
		{
			String in = scanner.next();
			//String out = "";
			if(in.equals("0"))
			{
				break;
			}
			
			int sum = 0;
			for(int i=0; i<in.length(); i++)
			{
				char c = in.charAt(i);
				sum += c - '0';
			}
			
			System.out.println(sum+"");
		}
	} main {
		Scanner scanner = new Scanner(System.in);
		
		for(;;)
		{
			String in = scanner.next();
			//String out = "";
			if(in.equals("0"))
			{
				break;
			}
			
			int sum = 0;
			for(int i=0; i<in.length(); i++)
			{
				char c = in.charAt(i);
				sum += c - '0';
			}
			
			System.out.println(sum+"");
		}
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) for(;;)
		{
			String in = scanner.next();
			//String out = "";
			if(in.equals("0"))
			{
				break;
			}
			
			int sum = 0;
			for(int i=0; i<in.length(); i++)
			{
				char c = in.charAt(i);
				sum += c - '0';
			}
			
			System.out.println(sum+"");
		} ; {
			String in = scanner.next();
			//String out = "";
			if(in.equals("0"))
			{
				break;
			}
			
			int sum = 0;
			for(int i=0; i<in.length(); i++)
			{
				char c = in.charAt(i);
				sum += c - '0';
			}
			
			System.out.println(sum+"");
		} {
			String in = scanner.next();
			//String out = "";
			if(in.equals("0"))
			{
				break;
			}
			
			int sum = 0;
			for(int i=0; i<in.length(); i++)
			{
				char c = in.charAt(i);
				sum += c - '0';
			}
			
			System.out.println(sum+"");
		} String in = scanner.next(); in scanner.next() scanner.next scanner if(in.equals("0"))
			{
				break;
			} in.equals("0") in.equals in "0" {
				break;
			} break; int sum = 0; sum 0 for(int i=0; i<in.length(); i++)
			{
				char c = in.charAt(i);
				sum += c - '0';
			} int i=0; int i=0; i 0 i<in.length() i in.length() in.length in i++ i++ i {
				char c = in.charAt(i);
				sum += c - '0';
			} {
				char c = in.charAt(i);
				sum += c - '0';
			} char c = in.charAt(i); c in.charAt(i) in.charAt in i sum += c - '0' sum c - '0' c '0' System.out.println(sum+"") System.out.println System.out System System.out sum+"" sum "" String[] args args public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(;;)
		{
			String in = scanner.next();
			//String out = "";
			if(in.equals("0"))
			{
				break;
			}
			
			int sum = 0;
			for(int i=0; i<in.length(); i++)
			{
				char c = in.charAt(i);
				sum += c - '0';
			}
			
			System.out.println(sum+"");
		}
	}
} public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(;;)
		{
			String in = scanner.next();
			//String out = "";
			if(in.equals("0"))
			{
				break;
			}
			
			int sum = 0;
			for(int i=0; i<in.length(); i++)
			{
				char c = in.charAt(i);
				sum += c - '0';
			}
			
			System.out.println(sum+"");
		}
	}
} Main
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(;;)
		{
			String in = scanner.next();
			//String out = "";
			if(in.equals("0"))
			{
				break;
			}
			
			int sum = 0;
			for(int i=0; i<in.length(); i++)
			{
				char c = in.charAt(i);
				sum += c - '0';
			}
			
			System.out.println(sum+"");
		}
	}
}