import java.util.Scanner;

public class Main {

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

		StringBuffer line = new StringBuffer(sc.nextLine());
		for (; !line.toString().equals("0");) {
			int sum = 0;
			for (int i = 0; i < line.length(); i++) {
				char ch = line.charAt(i);
				sum += ch - '0';
			}
			System.out.println(sum);
			
			line = new StringBuffer(sc.nextLine());
		}
		
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {

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

		StringBuffer line = new StringBuffer(sc.nextLine());
		for (; !line.toString().equals("0");) {
			int sum = 0;
			for (int i = 0; i < line.length(); i++) {
				char ch = line.charAt(i);
				sum += ch - '0';
			}
			System.out.println(sum);
			
			line = new StringBuffer(sc.nextLine());
		}
		
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		StringBuffer line = new StringBuffer(sc.nextLine());
		for (; !line.toString().equals("0");) {
			int sum = 0;
			for (int i = 0; i < line.length(); i++) {
				char ch = line.charAt(i);
				sum += ch - '0';
			}
			System.out.println(sum);
			
			line = new StringBuffer(sc.nextLine());
		}
		
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in); 

		StringBuffer line = new StringBuffer(sc.nextLine());
		for (; !line.toString().equals("0");) {
			int sum = 0;
			for (int i = 0; i < line.length(); i++) {
				char ch = line.charAt(i);
				sum += ch - '0';
			}
			System.out.println(sum);
			
			line = new StringBuffer(sc.nextLine());
		}
		
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuffer line = new StringBuffer(sc.nextLine()); line new StringBuffer(sc.nextLine()) for (; !line.toString().equals("0");) {
			int sum = 0;
			for (int i = 0; i < line.length(); i++) {
				char ch = line.charAt(i);
				sum += ch - '0';
			}
			System.out.println(sum);
			
			line = new StringBuffer(sc.nextLine());
		} ; !line.toString().equals("0") line.toString().equals("0") line.toString().equals line.toString() line.toString line "0" {
			int sum = 0;
			for (int i = 0; i < line.length(); i++) {
				char ch = line.charAt(i);
				sum += ch - '0';
			}
			System.out.println(sum);
			
			line = new StringBuffer(sc.nextLine());
		} {
			int sum = 0;
			for (int i = 0; i < line.length(); i++) {
				char ch = line.charAt(i);
				sum += ch - '0';
			}
			System.out.println(sum);
			
			line = new StringBuffer(sc.nextLine());
		} int sum = 0; sum 0 for (int i = 0; i < line.length(); i++) {
				char ch = line.charAt(i);
				sum += ch - '0';
			} int i = 0; int i = 0; i 0 i < line.length() i line.length() line.length line i++ i++ i {
				char ch = line.charAt(i);
				sum += ch - '0';
			} {
				char ch = line.charAt(i);
				sum += ch - '0';
			} char ch = line.charAt(i); ch line.charAt(i) line.charAt line i sum += ch - '0' sum ch - '0' ch '0' System.out.println(sum) System.out.println System.out System System.out sum line = new StringBuffer(sc.nextLine()) line new StringBuffer(sc.nextLine()) sc.close() sc.close sc String[] args args public class Main {

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

		StringBuffer line = new StringBuffer(sc.nextLine());
		for (; !line.toString().equals("0");) {
			int sum = 0;
			for (int i = 0; i < line.length(); i++) {
				char ch = line.charAt(i);
				sum += ch - '0';
			}
			System.out.println(sum);
			
			line = new StringBuffer(sc.nextLine());
		}
		
		sc.close();
	}
} public class Main {

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

		StringBuffer line = new StringBuffer(sc.nextLine());
		for (; !line.toString().equals("0");) {
			int sum = 0;
			for (int i = 0; i < line.length(); i++) {
				char ch = line.charAt(i);
				sum += ch - '0';
			}
			System.out.println(sum);
			
			line = new StringBuffer(sc.nextLine());
		}
		
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {

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

		StringBuffer line = new StringBuffer(sc.nextLine());
		for (; !line.toString().equals("0");) {
			int sum = 0;
			for (int i = 0; i < line.length(); i++) {
				char ch = line.charAt(i);
				sum += ch - '0';
			}
			System.out.println(sum);
			
			line = new StringBuffer(sc.nextLine());
		}
		
		sc.close();
	}
}