import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		while(true) {
			String str=in.next(); char[] num=str.toCharArray();
			if(num[0]=='0')break;
			int sum=0;
			for(int i=0;i<num.length;i++)sum+=num[i]-48;
			out.println(sum);
		}
		out.flush();
	}

}
 import java.util.*; util.* java import java.io.*; io.* java public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		while(true) {
			String str=in.next(); char[] num=str.toCharArray();
			if(num[0]=='0')break;
			int sum=0;
			for(int i=0;i<num.length;i++)sum+=num[i]-48;
			out.println(sum);
		}
		out.flush();
	}

} Main public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		while(true) {
			String str=in.next(); char[] num=str.toCharArray();
			if(num[0]=='0')break;
			int sum=0;
			for(int i=0;i<num.length;i++)sum+=num[i]-48;
			out.println(sum);
		}
		out.flush();
	} main {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		while(true) {
			String str=in.next(); char[] num=str.toCharArray();
			if(num[0]=='0')break;
			int sum=0;
			for(int i=0;i<num.length;i++)sum+=num[i]-48;
			out.println(sum);
		}
		out.flush();
	} Scanner in=new Scanner(System.in); in new Scanner(System.in) PrintWriter out=new PrintWriter(System.out); out new PrintWriter(System.out) while(true) {
			String str=in.next(); char[] num=str.toCharArray();
			if(num[0]=='0')break;
			int sum=0;
			for(int i=0;i<num.length;i++)sum+=num[i]-48;
			out.println(sum);
		} true {
			String str=in.next(); char[] num=str.toCharArray();
			if(num[0]=='0')break;
			int sum=0;
			for(int i=0;i<num.length;i++)sum+=num[i]-48;
			out.println(sum);
		} String str=in.next(); str in.next() in.next in char[] num=str.toCharArray(); num str.toCharArray() str.toCharArray str if(num[0]=='0')break; num[0]=='0' num[0] num 0 '0' break; int sum=0; sum 0 for(int i=0;i<num.length;i++)sum+=num[i]-48; int i=0; int i=0; i 0 i<num.length i num.length num num.length i++ i++ i sum+=num[i]-48; sum+=num[i]-48 sum num[i]-48 num[i] num i 48 out.println(sum) out.println out sum out.flush() out.flush out String[] args args public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		while(true) {
			String str=in.next(); char[] num=str.toCharArray();
			if(num[0]=='0')break;
			int sum=0;
			for(int i=0;i<num.length;i++)sum+=num[i]-48;
			out.println(sum);
		}
		out.flush();
	}

} public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		while(true) {
			String str=in.next(); char[] num=str.toCharArray();
			if(num[0]=='0')break;
			int sum=0;
			for(int i=0;i<num.length;i++)sum+=num[i]-48;
			out.println(sum);
		}
		out.flush();
	}

} Main
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		while(true) {
			String str=in.next(); char[] num=str.toCharArray();
			if(num[0]=='0')break;
			int sum=0;
			for(int i=0;i<num.length;i++)sum+=num[i]-48;
			out.println(sum);
		}
		out.flush();
	}

}

