import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			String num = sc.next();
			if (num.equals("0"))
			{
				return;
			}

			int sum = 0;
			for (int i = 0; i < num.length(); i++)
			{
				sum += (num.charAt(i) - '0');
			}

			System.out.println(sum);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			String num = sc.next();
			if (num.equals("0"))
			{
				return;
			}

			int sum = 0;
			for (int i = 0; i < num.length(); i++)
			{
				sum += (num.charAt(i) - '0');
			}

			System.out.println(sum);
		}
	}
} Main public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			String num = sc.next();
			if (num.equals("0"))
			{
				return;
			}

			int sum = 0;
			for (int i = 0; i < num.length(); i++)
			{
				sum += (num.charAt(i) - '0');
			}

			System.out.println(sum);
		}
	} main {
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			String num = sc.next();
			if (num.equals("0"))
			{
				return;
			}

			int sum = 0;
			for (int i = 0; i < num.length(); i++)
			{
				sum += (num.charAt(i) - '0');
			}

			System.out.println(sum);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true)
		{
			String num = sc.next();
			if (num.equals("0"))
			{
				return;
			}

			int sum = 0;
			for (int i = 0; i < num.length(); i++)
			{
				sum += (num.charAt(i) - '0');
			}

			System.out.println(sum);
		} true {
			String num = sc.next();
			if (num.equals("0"))
			{
				return;
			}

			int sum = 0;
			for (int i = 0; i < num.length(); i++)
			{
				sum += (num.charAt(i) - '0');
			}

			System.out.println(sum);
		} String num = sc.next(); num sc.next() sc.next sc if (num.equals("0"))
			{
				return;
			} num.equals("0") num.equals num "0" {
				return;
			} return; int sum = 0; sum 0 for (int i = 0; i < num.length(); i++)
			{
				sum += (num.charAt(i) - '0');
			} int i = 0; int i = 0; i 0 i < num.length() i num.length() num.length num i++ i++ i {
				sum += (num.charAt(i) - '0');
			} {
				sum += (num.charAt(i) - '0');
			} sum += (num.charAt(i) - '0') sum (num.charAt(i) - '0') num.charAt(i) num.charAt num 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 sc = new Scanner(System.in);

		while (true)
		{
			String num = sc.next();
			if (num.equals("0"))
			{
				return;
			}

			int sum = 0;
			for (int i = 0; i < num.length(); i++)
			{
				sum += (num.charAt(i) - '0');
			}

			System.out.println(sum);
		}
	}
} public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			String num = sc.next();
			if (num.equals("0"))
			{
				return;
			}

			int sum = 0;
			for (int i = 0; i < num.length(); i++)
			{
				sum += (num.charAt(i) - '0');
			}

			System.out.println(sum);
		}
	}
} Main
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			String num = sc.next();
			if (num.equals("0"))
			{
				return;
			}

			int sum = 0;
			for (int i = 0; i < num.length(); i++)
			{
				sum += (num.charAt(i) - '0');
			}

			System.out.println(sum);
		}
	}
}
