

import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		int sum = 0;
		StringBuilder out = new StringBuilder();
		
		// 標準入力
		Scanner sc = new Scanner(System.in);
		
		while (sc.hasNext()) {
			String words = sc.next();
			
			if(words.equals("0"))
			break;
			
			char ch[] = words.toCharArray();

			//
			sum = 0;
			for (int i = 0; i < ch.length; i++) {
				//
				String str = String.valueOf(ch[i]);
				int num = Integer.parseInt(str);
				sum += num;
			}
			out = new StringBuilder(out+(sum+"\n"));
		}

		// 結果出力
		System.out.print(out);

	}

} import java.util.Scanner; Scanner java.util public class Main{

	public static void main(String[] args) {

		int sum = 0;
		StringBuilder out = new StringBuilder();
		
		// 標準入力
		Scanner sc = new Scanner(System.in);
		
		while (sc.hasNext()) {
			String words = sc.next();
			
			if(words.equals("0"))
			break;
			
			char ch[] = words.toCharArray();

			//
			sum = 0;
			for (int i = 0; i < ch.length; i++) {
				//
				String str = String.valueOf(ch[i]);
				int num = Integer.parseInt(str);
				sum += num;
			}
			out = new StringBuilder(out+(sum+"\n"));
		}

		// 結果出力
		System.out.print(out);

	}

} Main public static void main(String[] args) {

		int sum = 0;
		StringBuilder out = new StringBuilder();
		
		// 標準入力
		Scanner sc = new Scanner(System.in);
		
		while (sc.hasNext()) {
			String words = sc.next();
			
			if(words.equals("0"))
			break;
			
			char ch[] = words.toCharArray();

			//
			sum = 0;
			for (int i = 0; i < ch.length; i++) {
				//
				String str = String.valueOf(ch[i]);
				int num = Integer.parseInt(str);
				sum += num;
			}
			out = new StringBuilder(out+(sum+"\n"));
		}

		// 結果出力
		System.out.print(out);

	} main {

		int sum = 0;
		StringBuilder out = new StringBuilder();
		
		// 標準入力
		Scanner sc = new Scanner(System.in);
		
		while (sc.hasNext()) {
			String words = sc.next();
			
			if(words.equals("0"))
			break;
			
			char ch[] = words.toCharArray();

			//
			sum = 0;
			for (int i = 0; i < ch.length; i++) {
				//
				String str = String.valueOf(ch[i]);
				int num = Integer.parseInt(str);
				sum += num;
			}
			out = new StringBuilder(out+(sum+"\n"));
		}

		// 結果出力
		System.out.print(out);

	} int sum = 0; sum 0 StringBuilder out = new StringBuilder(); out new StringBuilder() Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (sc.hasNext()) {
			String words = sc.next();
			
			if(words.equals("0"))
			break;
			
			char ch[] = words.toCharArray();

			//
			sum = 0;
			for (int i = 0; i < ch.length; i++) {
				//
				String str = String.valueOf(ch[i]);
				int num = Integer.parseInt(str);
				sum += num;
			}
			out = new StringBuilder(out+(sum+"\n"));
		} sc.hasNext() sc.hasNext sc {
			String words = sc.next();
			
			if(words.equals("0"))
			break;
			
			char ch[] = words.toCharArray();

			//
			sum = 0;
			for (int i = 0; i < ch.length; i++) {
				//
				String str = String.valueOf(ch[i]);
				int num = Integer.parseInt(str);
				sum += num;
			}
			out = new StringBuilder(out+(sum+"\n"));
		} String words = sc.next(); words sc.next() sc.next sc if(words.equals("0"))
			break; words.equals("0") words.equals words "0" break; char ch[] = words.toCharArray(); ch words.toCharArray() words.toCharArray words sum = 0 sum 0 for (int i = 0; i < ch.length; i++) {
				//
				String str = String.valueOf(ch[i]);
				int num = Integer.parseInt(str);
				sum += num;
			} int i = 0; int i = 0; i 0 i < ch.length i ch.length ch ch.length i++ i++ i {
				//
				String str = String.valueOf(ch[i]);
				int num = Integer.parseInt(str);
				sum += num;
			} {
				//
				String str = String.valueOf(ch[i]);
				int num = Integer.parseInt(str);
				sum += num;
			} String str = String.valueOf(ch[i]); str String.valueOf(ch[i]) String.valueOf String ch[i] ch i int num = Integer.parseInt(str); num Integer.parseInt(str) Integer.parseInt Integer str sum += num sum num out = new StringBuilder(out+(sum+"\n")) out new StringBuilder(out+(sum+"\n")) System.out.print(out) System.out.print System.out System System.out out String[] args args public class Main{

	public static void main(String[] args) {

		int sum = 0;
		StringBuilder out = new StringBuilder();
		
		// 標準入力
		Scanner sc = new Scanner(System.in);
		
		while (sc.hasNext()) {
			String words = sc.next();
			
			if(words.equals("0"))
			break;
			
			char ch[] = words.toCharArray();

			//
			sum = 0;
			for (int i = 0; i < ch.length; i++) {
				//
				String str = String.valueOf(ch[i]);
				int num = Integer.parseInt(str);
				sum += num;
			}
			out = new StringBuilder(out+(sum+"\n"));
		}

		// 結果出力
		System.out.print(out);

	}

} public class Main{

	public static void main(String[] args) {

		int sum = 0;
		StringBuilder out = new StringBuilder();
		
		// 標準入力
		Scanner sc = new Scanner(System.in);
		
		while (sc.hasNext()) {
			String words = sc.next();
			
			if(words.equals("0"))
			break;
			
			char ch[] = words.toCharArray();

			//
			sum = 0;
			for (int i = 0; i < ch.length; i++) {
				//
				String str = String.valueOf(ch[i]);
				int num = Integer.parseInt(str);
				sum += num;
			}
			out = new StringBuilder(out+(sum+"\n"));
		}

		// 結果出力
		System.out.print(out);

	}

} Main


import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		int sum = 0;
		StringBuilder out = new StringBuilder();
		
		// 標準入力
		Scanner sc = new Scanner(System.in);
		
		while (sc.hasNext()) {
			String words = sc.next();
			
			if(words.equals("0"))
			break;
			
			char ch[] = words.toCharArray();

			//
			sum = 0;
			for (int i = 0; i < ch.length; i++) {
				//
				String str = String.valueOf(ch[i]);
				int num = Integer.parseInt(str);
				sum += num;
			}
			out = new StringBuilder(out+(sum+"\n"));
		}

		// 結果出力
		System.out.print(out);

	}

}