
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String str = null;
			String[] strArr = null;
			StringBuilder sb = new StringBuilder();
			while(true){
				str = br.readLine();
				if(str.equals("0")){
					break;
				}

				strArr = str.split("");
				long sum = 0;
				int len = str.length();
				for(int i=0;i<len;i++){
					sum += Integer.parseInt(strArr[i+1]);
				}

				sb.append(sum).append("\n");
			}

			System.out.print(sb.toString());

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (br != null) {
					br.close();
				}
			} catch (IOException ioe) {
			}

		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String str = null;
			String[] strArr = null;
			StringBuilder sb = new StringBuilder();
			while(true){
				str = br.readLine();
				if(str.equals("0")){
					break;
				}

				strArr = str.split("");
				long sum = 0;
				int len = str.length();
				for(int i=0;i<len;i++){
					sum += Integer.parseInt(strArr[i+1]);
				}

				sb.append(sum).append("\n");
			}

			System.out.print(sb.toString());

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (br != null) {
					br.close();
				}
			} catch (IOException ioe) {
			}

		}
	}
} Main public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String str = null;
			String[] strArr = null;
			StringBuilder sb = new StringBuilder();
			while(true){
				str = br.readLine();
				if(str.equals("0")){
					break;
				}

				strArr = str.split("");
				long sum = 0;
				int len = str.length();
				for(int i=0;i<len;i++){
					sum += Integer.parseInt(strArr[i+1]);
				}

				sb.append(sum).append("\n");
			}

			System.out.print(sb.toString());

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (br != null) {
					br.close();
				}
			} catch (IOException ioe) {
			}

		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String str = null;
			String[] strArr = null;
			StringBuilder sb = new StringBuilder();
			while(true){
				str = br.readLine();
				if(str.equals("0")){
					break;
				}

				strArr = str.split("");
				long sum = 0;
				int len = str.length();
				for(int i=0;i<len;i++){
					sum += Integer.parseInt(strArr[i+1]);
				}

				sb.append(sum).append("\n");
			}

			System.out.print(sb.toString());

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (br != null) {
					br.close();
				}
			} catch (IOException ioe) {
			}

		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) try {

			String str = null;
			String[] strArr = null;
			StringBuilder sb = new StringBuilder();
			while(true){
				str = br.readLine();
				if(str.equals("0")){
					break;
				}

				strArr = str.split("");
				long sum = 0;
				int len = str.length();
				for(int i=0;i<len;i++){
					sum += Integer.parseInt(strArr[i+1]);
				}

				sb.append(sum).append("\n");
			}

			System.out.print(sb.toString());

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (br != null) {
					br.close();
				}
			} catch (IOException ioe) {
			}

		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			try {
				if (br != null) {
					br.close();
				}
			} catch (IOException ioe) {
			}

		} try {
				if (br != null) {
					br.close();
				}
			} catch (IOException ioe) {
			} catch (IOException ioe) {
			} IOException ioe {
			} {
				if (br != null) {
					br.close();
				}
			} if (br != null) {
					br.close();
				} br != null br null {
					br.close();
				} br.close() br.close br {

			String str = null;
			String[] strArr = null;
			StringBuilder sb = new StringBuilder();
			while(true){
				str = br.readLine();
				if(str.equals("0")){
					break;
				}

				strArr = str.split("");
				long sum = 0;
				int len = str.length();
				for(int i=0;i<len;i++){
					sum += Integer.parseInt(strArr[i+1]);
				}

				sb.append(sum).append("\n");
			}

			System.out.print(sb.toString());

		} String str = null; str null String[] strArr = null; strArr null StringBuilder sb = new StringBuilder(); sb new StringBuilder() while(true){
				str = br.readLine();
				if(str.equals("0")){
					break;
				}

				strArr = str.split("");
				long sum = 0;
				int len = str.length();
				for(int i=0;i<len;i++){
					sum += Integer.parseInt(strArr[i+1]);
				}

				sb.append(sum).append("\n");
			} true {
				str = br.readLine();
				if(str.equals("0")){
					break;
				}

				strArr = str.split("");
				long sum = 0;
				int len = str.length();
				for(int i=0;i<len;i++){
					sum += Integer.parseInt(strArr[i+1]);
				}

				sb.append(sum).append("\n");
			} str = br.readLine() str br.readLine() br.readLine br if(str.equals("0")){
					break;
				} str.equals("0") str.equals str "0" {
					break;
				} break; strArr = str.split("") strArr str.split("") str.split str "" long sum = 0; sum 0 int len = str.length(); len str.length() str.length str for(int i=0;i<len;i++){
					sum += Integer.parseInt(strArr[i+1]);
				} int i=0; int i=0; i 0 i<len i len i++ i++ i {
					sum += Integer.parseInt(strArr[i+1]);
				} {
					sum += Integer.parseInt(strArr[i+1]);
				} sum += Integer.parseInt(strArr[i+1]) sum Integer.parseInt(strArr[i+1]) Integer.parseInt Integer strArr[i+1] strArr i+1 i 1 sb.append(sum).append("\n") sb.append(sum).append sb.append(sum) sb.append sb sum "\n" System.out.print(sb.toString()) System.out.print System.out System System.out sb.toString() sb.toString sb String[] args args public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String str = null;
			String[] strArr = null;
			StringBuilder sb = new StringBuilder();
			while(true){
				str = br.readLine();
				if(str.equals("0")){
					break;
				}

				strArr = str.split("");
				long sum = 0;
				int len = str.length();
				for(int i=0;i<len;i++){
					sum += Integer.parseInt(strArr[i+1]);
				}

				sb.append(sum).append("\n");
			}

			System.out.print(sb.toString());

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (br != null) {
					br.close();
				}
			} catch (IOException ioe) {
			}

		}
	}
} public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String str = null;
			String[] strArr = null;
			StringBuilder sb = new StringBuilder();
			while(true){
				str = br.readLine();
				if(str.equals("0")){
					break;
				}

				strArr = str.split("");
				long sum = 0;
				int len = str.length();
				for(int i=0;i<len;i++){
					sum += Integer.parseInt(strArr[i+1]);
				}

				sb.append(sum).append("\n");
			}

			System.out.print(sb.toString());

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (br != null) {
					br.close();
				}
			} catch (IOException ioe) {
			}

		}
	}
} Main

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String str = null;
			String[] strArr = null;
			StringBuilder sb = new StringBuilder();
			while(true){
				str = br.readLine();
				if(str.equals("0")){
					break;
				}

				strArr = str.split("");
				long sum = 0;
				int len = str.length();
				for(int i=0;i<len;i++){
					sum += Integer.parseInt(strArr[i+1]);
				}

				sb.append(sum).append("\n");
			}

			System.out.print(sb.toString());

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (br != null) {
					br.close();
				}
			} catch (IOException ioe) {
			}

		}
	}
}