
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		while(true)
		{
			String str = stdIn.next();
			
			if(str.charAt(0) == '0')
			{
				break;
			}
			
			int ans = 0;
			
			for(int i=0;i<str.length();i++)
			{
				ans += (int)str.charAt(i)-48;
			}
			
			System.out.println(ans);
			
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		while(true)
		{
			String str = stdIn.next();
			
			if(str.charAt(0) == '0')
			{
				break;
			}
			
			int ans = 0;
			
			for(int i=0;i<str.length();i++)
			{
				ans += (int)str.charAt(i)-48;
			}
			
			System.out.println(ans);
			
		}
	}
} Main public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		while(true)
		{
			String str = stdIn.next();
			
			if(str.charAt(0) == '0')
			{
				break;
			}
			
			int ans = 0;
			
			for(int i=0;i<str.length();i++)
			{
				ans += (int)str.charAt(i)-48;
			}
			
			System.out.println(ans);
			
		}
	} main {
		Scanner stdIn = new Scanner(System.in);
		
		while(true)
		{
			String str = stdIn.next();
			
			if(str.charAt(0) == '0')
			{
				break;
			}
			
			int ans = 0;
			
			for(int i=0;i<str.length();i++)
			{
				ans += (int)str.charAt(i)-48;
			}
			
			System.out.println(ans);
			
		}
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) while(true)
		{
			String str = stdIn.next();
			
			if(str.charAt(0) == '0')
			{
				break;
			}
			
			int ans = 0;
			
			for(int i=0;i<str.length();i++)
			{
				ans += (int)str.charAt(i)-48;
			}
			
			System.out.println(ans);
			
		} true {
			String str = stdIn.next();
			
			if(str.charAt(0) == '0')
			{
				break;
			}
			
			int ans = 0;
			
			for(int i=0;i<str.length();i++)
			{
				ans += (int)str.charAt(i)-48;
			}
			
			System.out.println(ans);
			
		} String str = stdIn.next(); str stdIn.next() stdIn.next stdIn if(str.charAt(0) == '0')
			{
				break;
			} str.charAt(0) == '0' str.charAt(0) str.charAt str 0 '0' {
				break;
			} break; int ans = 0; ans 0 for(int i=0;i<str.length();i++)
			{
				ans += (int)str.charAt(i)-48;
			} int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
				ans += (int)str.charAt(i)-48;
			} {
				ans += (int)str.charAt(i)-48;
			} ans += (int)str.charAt(i)-48 ans (int)str.charAt(i)-48 (int)str.charAt(i) str.charAt str i 48 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		while(true)
		{
			String str = stdIn.next();
			
			if(str.charAt(0) == '0')
			{
				break;
			}
			
			int ans = 0;
			
			for(int i=0;i<str.length();i++)
			{
				ans += (int)str.charAt(i)-48;
			}
			
			System.out.println(ans);
			
		}
	}
} public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		while(true)
		{
			String str = stdIn.next();
			
			if(str.charAt(0) == '0')
			{
				break;
			}
			
			int ans = 0;
			
			for(int i=0;i<str.length();i++)
			{
				ans += (int)str.charAt(i)-48;
			}
			
			System.out.println(ans);
			
		}
	}
} Main

import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		while(true)
		{
			String str = stdIn.next();
			
			if(str.charAt(0) == '0')
			{
				break;
			}
			
			int ans = 0;
			
			for(int i=0;i<str.length();i++)
			{
				ans += (int)str.charAt(i)-48;
			}
			
			System.out.println(ans);
			
		}
	}
}