import java.util.Scanner;
import java.lang.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int sum;
		String s;
		while (true)
		{
			s = input.nextLine();
			if(s.length() == 1 && s.charAt(0) == '0')
				break;
			else
			{
				sum = 0;
				for(int i = 0; i < s.length(); i++)
				{
					sum += (int)(s.charAt(i)-'0');
				}
				System.out.println(sum);
			}
		}
	}
} import java.util.Scanner; Scanner java.util import java.lang.*; lang.* java public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int sum;
		String s;
		while (true)
		{
			s = input.nextLine();
			if(s.length() == 1 && s.charAt(0) == '0')
				break;
			else
			{
				sum = 0;
				for(int i = 0; i < s.length(); i++)
				{
					sum += (int)(s.charAt(i)-'0');
				}
				System.out.println(sum);
			}
		}
	}
} Main public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int sum;
		String s;
		while (true)
		{
			s = input.nextLine();
			if(s.length() == 1 && s.charAt(0) == '0')
				break;
			else
			{
				sum = 0;
				for(int i = 0; i < s.length(); i++)
				{
					sum += (int)(s.charAt(i)-'0');
				}
				System.out.println(sum);
			}
		}
	} main {
		Scanner input = new Scanner(System.in);
		int sum;
		String s;
		while (true)
		{
			s = input.nextLine();
			if(s.length() == 1 && s.charAt(0) == '0')
				break;
			else
			{
				sum = 0;
				for(int i = 0; i < s.length(); i++)
				{
					sum += (int)(s.charAt(i)-'0');
				}
				System.out.println(sum);
			}
		}
	} Scanner input = new Scanner(System.in); input new Scanner(System.in) int sum; sum String s; s while (true)
		{
			s = input.nextLine();
			if(s.length() == 1 && s.charAt(0) == '0')
				break;
			else
			{
				sum = 0;
				for(int i = 0; i < s.length(); i++)
				{
					sum += (int)(s.charAt(i)-'0');
				}
				System.out.println(sum);
			}
		} true {
			s = input.nextLine();
			if(s.length() == 1 && s.charAt(0) == '0')
				break;
			else
			{
				sum = 0;
				for(int i = 0; i < s.length(); i++)
				{
					sum += (int)(s.charAt(i)-'0');
				}
				System.out.println(sum);
			}
		} s = input.nextLine() s input.nextLine() input.nextLine input if(s.length() == 1 && s.charAt(0) == '0')
				break;
			else
			{
				sum = 0;
				for(int i = 0; i < s.length(); i++)
				{
					sum += (int)(s.charAt(i)-'0');
				}
				System.out.println(sum);
			} s.length() == 1 && s.charAt(0) == '0' s.length() == 1 s.length() s.length s 1 s.charAt(0) == '0' s.charAt(0) s.charAt s 0 '0' break; {
				sum = 0;
				for(int i = 0; i < s.length(); i++)
				{
					sum += (int)(s.charAt(i)-'0');
				}
				System.out.println(sum);
			} sum = 0 sum 0 for(int i = 0; i < s.length(); i++)
				{
					sum += (int)(s.charAt(i)-'0');
				} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
					sum += (int)(s.charAt(i)-'0');
				} {
					sum += (int)(s.charAt(i)-'0');
				} sum += (int)(s.charAt(i)-'0') sum (int)(s.charAt(i)-'0') s.charAt(i) s.charAt s i '0' 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[])
	{
		Scanner input = new Scanner(System.in);
		int sum;
		String s;
		while (true)
		{
			s = input.nextLine();
			if(s.length() == 1 && s.charAt(0) == '0')
				break;
			else
			{
				sum = 0;
				for(int i = 0; i < s.length(); i++)
				{
					sum += (int)(s.charAt(i)-'0');
				}
				System.out.println(sum);
			}
		}
	}
} public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int sum;
		String s;
		while (true)
		{
			s = input.nextLine();
			if(s.length() == 1 && s.charAt(0) == '0')
				break;
			else
			{
				sum = 0;
				for(int i = 0; i < s.length(); i++)
				{
					sum += (int)(s.charAt(i)-'0');
				}
				System.out.println(sum);
			}
		}
	}
} Main
import java.util.Scanner;
import java.lang.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int sum;
		String s;
		while (true)
		{
			s = input.nextLine();
			if(s.length() == 1 && s.charAt(0) == '0')
				break;
			else
			{
				sum = 0;
				for(int i = 0; i < s.length(); i++)
				{
					sum += (int)(s.charAt(i)-'0');
				}
				System.out.println(sum);
			}
		}
	}
}