/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);

		List<String> list = new ArrayList<String>();
        
		while (true) {
			String num = scan.next();
			
			if (num.equals("0")) {
				break;
			}
			
			list.add(num);
		}

		for (String s : list) {
			int sum = 0;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(sum);
		}    	
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);

		List<String> list = new ArrayList<String>();
        
		while (true) {
			String num = scan.next();
			
			if (num.equals("0")) {
				break;
			}
			
			list.add(num);
		}

		for (String s : list) {
			int sum = 0;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(sum);
		}    	
	}
} Main public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);

		List<String> list = new ArrayList<String>();
        
		while (true) {
			String num = scan.next();
			
			if (num.equals("0")) {
				break;
			}
			
			list.add(num);
		}

		for (String s : list) {
			int sum = 0;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(sum);
		}    	
	} main {
		Scanner scan = new Scanner(System.in);

		List<String> list = new ArrayList<String>();
        
		while (true) {
			String num = scan.next();
			
			if (num.equals("0")) {
				break;
			}
			
			list.add(num);
		}

		for (String s : list) {
			int sum = 0;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(sum);
		}    	
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) List<String> list = new ArrayList<String>(); list new ArrayList<String>() while (true) {
			String num = scan.next();
			
			if (num.equals("0")) {
				break;
			}
			
			list.add(num);
		} true {
			String num = scan.next();
			
			if (num.equals("0")) {
				break;
			}
			
			list.add(num);
		} String num = scan.next(); num scan.next() scan.next scan if (num.equals("0")) {
				break;
			} num.equals("0") num.equals num "0" {
				break;
			} break; list.add(num) list.add list num for (String s : list) {
			int sum = 0;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(sum);
		} String s list {
			int sum = 0;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(sum);
		} {
			int sum = 0;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(sum);
		} int sum = 0; sum 0 for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(s.substring(i, i+1));
			} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
				sum += Integer.parseInt(s.substring(i, i+1));
			} {
				sum += Integer.parseInt(s.substring(i, i+1));
			} sum += Integer.parseInt(s.substring(i, i+1)) sum Integer.parseInt(s.substring(i, i+1)) Integer.parseInt Integer s.substring(i, i+1) s.substring s i i+1 i 1 System.out.println(sum) System.out.println System.out System System.out sum String[] args args
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);

		List<String> list = new ArrayList<String>();
        
		while (true) {
			String num = scan.next();
			
			if (num.equals("0")) {
				break;
			}
			
			list.add(num);
		}

		for (String s : list) {
			int sum = 0;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(sum);
		}    	
	}
}