import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import static java.math.BigInteger.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(!"0".equals(str = br.readLine())){
			System.out.println(sum(str));
		}
	}

	private static int sum(String str) {
		BigInteger n = new BigInteger(str);
		if(n.compareTo(TEN) < 0){
			return Integer.parseInt(n.toString());
		}else{
			return Integer.parseInt(n.remainder(TEN).toString()) + sum(n.divide(TEN).toString());
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.math.BigInteger; BigInteger java.math import static java.math.BigInteger.*; import static java.math.BigInteger.*; import static java.math.BigInteger.*; public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(!"0".equals(str = br.readLine())){
			System.out.println(sum(str));
		}
	}

	private static int sum(String str) {
		BigInteger n = new BigInteger(str);
		if(n.compareTo(TEN) < 0){
			return Integer.parseInt(n.toString());
		}else{
			return Integer.parseInt(n.remainder(TEN).toString()) + sum(n.divide(TEN).toString());
		}
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(!"0".equals(str = br.readLine())){
			System.out.println(sum(str));
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(!"0".equals(str = br.readLine())){
			System.out.println(sum(str));
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str while(!"0".equals(str = br.readLine())){
			System.out.println(sum(str));
		} !"0".equals(str = br.readLine()) "0".equals(str = br.readLine()) "0".equals "0" str = br.readLine() str br.readLine() br.readLine br {
			System.out.println(sum(str));
		} System.out.println(sum(str)) System.out.println System.out System System.out sum(str) sum str String[] args args private static int sum(String str) {
		BigInteger n = new BigInteger(str);
		if(n.compareTo(TEN) < 0){
			return Integer.parseInt(n.toString());
		}else{
			return Integer.parseInt(n.remainder(TEN).toString()) + sum(n.divide(TEN).toString());
		}
	} sum {
		BigInteger n = new BigInteger(str);
		if(n.compareTo(TEN) < 0){
			return Integer.parseInt(n.toString());
		}else{
			return Integer.parseInt(n.remainder(TEN).toString()) + sum(n.divide(TEN).toString());
		}
	} BigInteger n = new BigInteger(str); n new BigInteger(str) if(n.compareTo(TEN) < 0){
			return Integer.parseInt(n.toString());
		}else{
			return Integer.parseInt(n.remainder(TEN).toString()) + sum(n.divide(TEN).toString());
		} n.compareTo(TEN) < 0 n.compareTo(TEN) n.compareTo n TEN 0 {
			return Integer.parseInt(n.toString());
		} return Integer.parseInt(n.toString()); Integer.parseInt(n.toString()) Integer.parseInt Integer n.toString() n.toString n {
			return Integer.parseInt(n.remainder(TEN).toString()) + sum(n.divide(TEN).toString());
		} return Integer.parseInt(n.remainder(TEN).toString()) + sum(n.divide(TEN).toString()); Integer.parseInt(n.remainder(TEN).toString()) + sum(n.divide(TEN).toString()) Integer.parseInt(n.remainder(TEN).toString()) Integer.parseInt Integer n.remainder(TEN).toString() n.remainder(TEN).toString n.remainder(TEN) n.remainder n TEN sum(n.divide(TEN).toString()) sum n.divide(TEN).toString() n.divide(TEN).toString n.divide(TEN) n.divide n TEN String str str public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(!"0".equals(str = br.readLine())){
			System.out.println(sum(str));
		}
	}

	private static int sum(String str) {
		BigInteger n = new BigInteger(str);
		if(n.compareTo(TEN) < 0){
			return Integer.parseInt(n.toString());
		}else{
			return Integer.parseInt(n.remainder(TEN).toString()) + sum(n.divide(TEN).toString());
		}
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(!"0".equals(str = br.readLine())){
			System.out.println(sum(str));
		}
	}

	private static int sum(String str) {
		BigInteger n = new BigInteger(str);
		if(n.compareTo(TEN) < 0){
			return Integer.parseInt(n.toString());
		}else{
			return Integer.parseInt(n.remainder(TEN).toString()) + sum(n.divide(TEN).toString());
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import static java.math.BigInteger.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(!"0".equals(str = br.readLine())){
			System.out.println(sum(str));
		}
	}

	private static int sum(String str) {
		BigInteger n = new BigInteger(str);
		if(n.compareTo(TEN) < 0){
			return Integer.parseInt(n.toString());
		}else{
			return Integer.parseInt(n.remainder(TEN).toString()) + sum(n.divide(TEN).toString());
		}
	}
}