import java.math.BigDecimal;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws NumberFormatException {
		Scanner scan = new Scanner(System.in);
		while(true){
			BigDecimal x = scan.nextBigDecimal();
			if(x.equals(BigDecimal.ZERO)){
				break;
			}
			int sum = 0;
			for(; !x.equals(BigDecimal.ZERO); x = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN)){
				BigDecimal amari = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN);
				amari = amari.multiply(BigDecimal.TEN);
				sum += x.subtract(amari).intValue();
			}
			System.out.println(sum);
		}
	}
} import java.math.BigDecimal; BigDecimal java.math import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws NumberFormatException {
		Scanner scan = new Scanner(System.in);
		while(true){
			BigDecimal x = scan.nextBigDecimal();
			if(x.equals(BigDecimal.ZERO)){
				break;
			}
			int sum = 0;
			for(; !x.equals(BigDecimal.ZERO); x = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN)){
				BigDecimal amari = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN);
				amari = amari.multiply(BigDecimal.TEN);
				sum += x.subtract(amari).intValue();
			}
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args) throws NumberFormatException {
		Scanner scan = new Scanner(System.in);
		while(true){
			BigDecimal x = scan.nextBigDecimal();
			if(x.equals(BigDecimal.ZERO)){
				break;
			}
			int sum = 0;
			for(; !x.equals(BigDecimal.ZERO); x = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN)){
				BigDecimal amari = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN);
				amari = amari.multiply(BigDecimal.TEN);
				sum += x.subtract(amari).intValue();
			}
			System.out.println(sum);
		}
	} main {
		Scanner scan = new Scanner(System.in);
		while(true){
			BigDecimal x = scan.nextBigDecimal();
			if(x.equals(BigDecimal.ZERO)){
				break;
			}
			int sum = 0;
			for(; !x.equals(BigDecimal.ZERO); x = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN)){
				BigDecimal amari = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN);
				amari = amari.multiply(BigDecimal.TEN);
				sum += x.subtract(amari).intValue();
			}
			System.out.println(sum);
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while(true){
			BigDecimal x = scan.nextBigDecimal();
			if(x.equals(BigDecimal.ZERO)){
				break;
			}
			int sum = 0;
			for(; !x.equals(BigDecimal.ZERO); x = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN)){
				BigDecimal amari = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN);
				amari = amari.multiply(BigDecimal.TEN);
				sum += x.subtract(amari).intValue();
			}
			System.out.println(sum);
		} true {
			BigDecimal x = scan.nextBigDecimal();
			if(x.equals(BigDecimal.ZERO)){
				break;
			}
			int sum = 0;
			for(; !x.equals(BigDecimal.ZERO); x = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN)){
				BigDecimal amari = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN);
				amari = amari.multiply(BigDecimal.TEN);
				sum += x.subtract(amari).intValue();
			}
			System.out.println(sum);
		} BigDecimal x = scan.nextBigDecimal(); x scan.nextBigDecimal() scan.nextBigDecimal scan if(x.equals(BigDecimal.ZERO)){
				break;
			} x.equals(BigDecimal.ZERO) x.equals x BigDecimal.ZERO BigDecimal BigDecimal.ZERO {
				break;
			} break; int sum = 0; sum 0 for(; !x.equals(BigDecimal.ZERO); x = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN)){
				BigDecimal amari = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN);
				amari = amari.multiply(BigDecimal.TEN);
				sum += x.subtract(amari).intValue();
			} ; !x.equals(BigDecimal.ZERO) x.equals(BigDecimal.ZERO) x.equals x BigDecimal.ZERO BigDecimal BigDecimal.ZERO x = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN) x = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN) x x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN) x.divide x BigDecimal.TEN BigDecimal BigDecimal.TEN 0 BigDecimal.ROUND_DOWN BigDecimal BigDecimal.ROUND_DOWN {
				BigDecimal amari = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN);
				amari = amari.multiply(BigDecimal.TEN);
				sum += x.subtract(amari).intValue();
			} {
				BigDecimal amari = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN);
				amari = amari.multiply(BigDecimal.TEN);
				sum += x.subtract(amari).intValue();
			} BigDecimal amari = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN); amari x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN) x.divide x BigDecimal.TEN BigDecimal BigDecimal.TEN 0 BigDecimal.ROUND_DOWN BigDecimal BigDecimal.ROUND_DOWN amari = amari.multiply(BigDecimal.TEN) amari amari.multiply(BigDecimal.TEN) amari.multiply amari BigDecimal.TEN BigDecimal BigDecimal.TEN sum += x.subtract(amari).intValue() sum x.subtract(amari).intValue() x.subtract(amari).intValue x.subtract(amari) x.subtract x amari System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args) throws NumberFormatException {
		Scanner scan = new Scanner(System.in);
		while(true){
			BigDecimal x = scan.nextBigDecimal();
			if(x.equals(BigDecimal.ZERO)){
				break;
			}
			int sum = 0;
			for(; !x.equals(BigDecimal.ZERO); x = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN)){
				BigDecimal amari = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN);
				amari = amari.multiply(BigDecimal.TEN);
				sum += x.subtract(amari).intValue();
			}
			System.out.println(sum);
		}
	}
} public class Main {
	public static void main(String[] args) throws NumberFormatException {
		Scanner scan = new Scanner(System.in);
		while(true){
			BigDecimal x = scan.nextBigDecimal();
			if(x.equals(BigDecimal.ZERO)){
				break;
			}
			int sum = 0;
			for(; !x.equals(BigDecimal.ZERO); x = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN)){
				BigDecimal amari = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN);
				amari = amari.multiply(BigDecimal.TEN);
				sum += x.subtract(amari).intValue();
			}
			System.out.println(sum);
		}
	}
} Main
import java.math.BigDecimal;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws NumberFormatException {
		Scanner scan = new Scanner(System.in);
		while(true){
			BigDecimal x = scan.nextBigDecimal();
			if(x.equals(BigDecimal.ZERO)){
				break;
			}
			int sum = 0;
			for(; !x.equals(BigDecimal.ZERO); x = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN)){
				BigDecimal amari = x.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_DOWN);
				amari = amari.multiply(BigDecimal.TEN);
				sum += x.subtract(amari).intValue();
			}
			System.out.println(sum);
		}
	}
}