import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner in = new Scanner(System.in);
	String str;
	long num;
	int sum=0;
	char c;

	while(true){
	    str = in.next();
	    if(str.equals("0"))break;
	    sum=0;
	    for(int i=0;i<str.length();i++){
		c = str.charAt(i);
		sum+=Character.getNumericValue(c);
	    }
	    System.out.println(sum);
	}
    }
}
 import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
	Scanner in = new Scanner(System.in);
	String str;
	long num;
	int sum=0;
	char c;

	while(true){
	    str = in.next();
	    if(str.equals("0"))break;
	    sum=0;
	    for(int i=0;i<str.length();i++){
		c = str.charAt(i);
		sum+=Character.getNumericValue(c);
	    }
	    System.out.println(sum);
	}
    }
} Main public static void main(String[] args){
	Scanner in = new Scanner(System.in);
	String str;
	long num;
	int sum=0;
	char c;

	while(true){
	    str = in.next();
	    if(str.equals("0"))break;
	    sum=0;
	    for(int i=0;i<str.length();i++){
		c = str.charAt(i);
		sum+=Character.getNumericValue(c);
	    }
	    System.out.println(sum);
	}
    } main {
	Scanner in = new Scanner(System.in);
	String str;
	long num;
	int sum=0;
	char c;

	while(true){
	    str = in.next();
	    if(str.equals("0"))break;
	    sum=0;
	    for(int i=0;i<str.length();i++){
		c = str.charAt(i);
		sum+=Character.getNumericValue(c);
	    }
	    System.out.println(sum);
	}
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) String str; str long num; num int sum=0; sum 0 char c; c while(true){
	    str = in.next();
	    if(str.equals("0"))break;
	    sum=0;
	    for(int i=0;i<str.length();i++){
		c = str.charAt(i);
		sum+=Character.getNumericValue(c);
	    }
	    System.out.println(sum);
	} true {
	    str = in.next();
	    if(str.equals("0"))break;
	    sum=0;
	    for(int i=0;i<str.length();i++){
		c = str.charAt(i);
		sum+=Character.getNumericValue(c);
	    }
	    System.out.println(sum);
	} str = in.next() str in.next() in.next in if(str.equals("0"))break; str.equals("0") str.equals str "0" break; sum=0 sum 0 for(int i=0;i<str.length();i++){
		c = str.charAt(i);
		sum+=Character.getNumericValue(c);
	    } int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
		c = str.charAt(i);
		sum+=Character.getNumericValue(c);
	    } {
		c = str.charAt(i);
		sum+=Character.getNumericValue(c);
	    } c = str.charAt(i) c str.charAt(i) str.charAt str i sum+=Character.getNumericValue(c) sum Character.getNumericValue(c) Character.getNumericValue Character c 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){
	Scanner in = new Scanner(System.in);
	String str;
	long num;
	int sum=0;
	char c;

	while(true){
	    str = in.next();
	    if(str.equals("0"))break;
	    sum=0;
	    for(int i=0;i<str.length();i++){
		c = str.charAt(i);
		sum+=Character.getNumericValue(c);
	    }
	    System.out.println(sum);
	}
    }
} public class Main{
    public static void main(String[] args){
	Scanner in = new Scanner(System.in);
	String str;
	long num;
	int sum=0;
	char c;

	while(true){
	    str = in.next();
	    if(str.equals("0"))break;
	    sum=0;
	    for(int i=0;i<str.length();i++){
		c = str.charAt(i);
		sum+=Character.getNumericValue(c);
	    }
	    System.out.println(sum);
	}
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner in = new Scanner(System.in);
	String str;
	long num;
	int sum=0;
	char c;

	while(true){
	    str = in.next();
	    if(str.equals("0"))break;
	    sum=0;
	    for(int i=0;i<str.length();i++){
		c = str.charAt(i);
		sum+=Character.getNumericValue(c);
	    }
	    System.out.println(sum);
	}
    }
}

