import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String x=stdIn.nextLine();
			char c[]=x.toCharArray();
			if(c[0]=='0')
				break;
			int ans=0;
			for(int i=0;i<x.length();i++)
				ans+=c[i]-'0';
			System.out.println(ans);
		}
	}
} import java.util.*; util.* java import java.io.*; io.* java import java.lang.*; lang.* java import java.math.*; math.* java public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String x=stdIn.nextLine();
			char c[]=x.toCharArray();
			if(c[0]=='0')
				break;
			int ans=0;
			for(int i=0;i<x.length();i++)
				ans+=c[i]-'0';
			System.out.println(ans);
		}
	}
} Main public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String x=stdIn.nextLine();
			char c[]=x.toCharArray();
			if(c[0]=='0')
				break;
			int ans=0;
			for(int i=0;i<x.length();i++)
				ans+=c[i]-'0';
			System.out.println(ans);
		}
	} main {
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String x=stdIn.nextLine();
			char c[]=x.toCharArray();
			if(c[0]=='0')
				break;
			int ans=0;
			for(int i=0;i<x.length();i++)
				ans+=c[i]-'0';
			System.out.println(ans);
		}
	} Scanner stdIn=new Scanner(System.in); stdIn new Scanner(System.in) BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			String x=stdIn.nextLine();
			char c[]=x.toCharArray();
			if(c[0]=='0')
				break;
			int ans=0;
			for(int i=0;i<x.length();i++)
				ans+=c[i]-'0';
			System.out.println(ans);
		} true {
			String x=stdIn.nextLine();
			char c[]=x.toCharArray();
			if(c[0]=='0')
				break;
			int ans=0;
			for(int i=0;i<x.length();i++)
				ans+=c[i]-'0';
			System.out.println(ans);
		} String x=stdIn.nextLine(); x stdIn.nextLine() stdIn.nextLine stdIn char c[]=x.toCharArray(); c x.toCharArray() x.toCharArray x if(c[0]=='0')
				break; c[0]=='0' c[0] c 0 '0' break; int ans=0; ans 0 for(int i=0;i<x.length();i++)
				ans+=c[i]-'0'; int i=0; int i=0; i 0 i<x.length() i x.length() x.length x i++ i++ i ans+=c[i]-'0'; ans+=c[i]-'0' ans c[i]-'0' c[i] c i '0' System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String x=stdIn.nextLine();
			char c[]=x.toCharArray();
			if(c[0]=='0')
				break;
			int ans=0;
			for(int i=0;i<x.length();i++)
				ans+=c[i]-'0';
			System.out.println(ans);
		}
	}
} public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String x=stdIn.nextLine();
			char c[]=x.toCharArray();
			if(c[0]=='0')
				break;
			int ans=0;
			for(int i=0;i<x.length();i++)
				ans+=c[i]-'0';
			System.out.println(ans);
		}
	}
} Main
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String x=stdIn.nextLine();
			char c[]=x.toCharArray();
			if(c[0]=='0')
				break;
			int ans=0;
			for(int i=0;i<x.length();i++)
				ans+=c[i]-'0';
			System.out.println(ans);
		}
	}
}