import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
	Character objChar1;
	String str;
	char c;
	int i,num,sum;
	Scanner scan = new Scanner(System.in);
	while(true) {
	str=scan.next();
	if(str.equals("0"))
		break;
	sum=0;

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

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

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

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

	for (i=0;i<str.length();i++){
		c=str.charAt(i);
		num=Character.digit(c,10);
		sum+=num;
	}
	System.out.println(sum);
	} true {
	str=scan.next();
	if(str.equals("0"))
		break;
	sum=0;

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

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

	for (i=0;i<str.length();i++){
		c=str.charAt(i);
		num=Character.digit(c,10);
		sum+=num;
	}
	System.out.println(sum);
	}
}
} Main
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
	Character objChar1;
	String str;
	char c;
	int i,num,sum;
	Scanner scan = new Scanner(System.in);
	while(true) {
	str=scan.next();
	if(str.equals("0"))
		break;
	sum=0;

	for (i=0;i<str.length();i++){
		c=str.charAt(i);
		num=Character.digit(c,10);
		sum+=num;
	}
	System.out.println(sum);
	}
}
}