import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String [] s;
		int sum;
		
		while(true){
			String s1 = sc.next();
			s = new String[s1.length()];
	        sum = 0;
	        
	        for (int i = 0; i < s1.length(); i++) {
	        s[i] = String.valueOf(s1.charAt(i));
	        sum += Integer.valueOf(s[i]);
	        }
	        if(sum == 0){
	        	break;
	        }
	        System.out.println(sum);
	        s1 = new String();
		}
        sc.close();

	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String [] s;
		int sum;
		
		while(true){
			String s1 = sc.next();
			s = new String[s1.length()];
	        sum = 0;
	        
	        for (int i = 0; i < s1.length(); i++) {
	        s[i] = String.valueOf(s1.charAt(i));
	        sum += Integer.valueOf(s[i]);
	        }
	        if(sum == 0){
	        	break;
	        }
	        System.out.println(sum);
	        s1 = new String();
		}
        sc.close();

	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String [] s;
		int sum;
		
		while(true){
			String s1 = sc.next();
			s = new String[s1.length()];
	        sum = 0;
	        
	        for (int i = 0; i < s1.length(); i++) {
	        s[i] = String.valueOf(s1.charAt(i));
	        sum += Integer.valueOf(s[i]);
	        }
	        if(sum == 0){
	        	break;
	        }
	        System.out.println(sum);
	        s1 = new String();
		}
        sc.close();

	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String [] s;
		int sum;
		
		while(true){
			String s1 = sc.next();
			s = new String[s1.length()];
	        sum = 0;
	        
	        for (int i = 0; i < s1.length(); i++) {
	        s[i] = String.valueOf(s1.charAt(i));
	        sum += Integer.valueOf(s[i]);
	        }
	        if(sum == 0){
	        	break;
	        }
	        System.out.println(sum);
	        s1 = new String();
		}
        sc.close();

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String [] s; s int sum; sum while(true){
			String s1 = sc.next();
			s = new String[s1.length()];
	        sum = 0;
	        
	        for (int i = 0; i < s1.length(); i++) {
	        s[i] = String.valueOf(s1.charAt(i));
	        sum += Integer.valueOf(s[i]);
	        }
	        if(sum == 0){
	        	break;
	        }
	        System.out.println(sum);
	        s1 = new String();
		} true {
			String s1 = sc.next();
			s = new String[s1.length()];
	        sum = 0;
	        
	        for (int i = 0; i < s1.length(); i++) {
	        s[i] = String.valueOf(s1.charAt(i));
	        sum += Integer.valueOf(s[i]);
	        }
	        if(sum == 0){
	        	break;
	        }
	        System.out.println(sum);
	        s1 = new String();
		} String s1 = sc.next(); s1 sc.next() sc.next sc s = new String[s1.length()] s new String[s1.length()] s1.length() s1.length s1 sum = 0 sum 0 for (int i = 0; i < s1.length(); i++) {
	        s[i] = String.valueOf(s1.charAt(i));
	        sum += Integer.valueOf(s[i]);
	        } int i = 0; int i = 0; i 0 i < s1.length() i s1.length() s1.length s1 i++ i++ i {
	        s[i] = String.valueOf(s1.charAt(i));
	        sum += Integer.valueOf(s[i]);
	        } {
	        s[i] = String.valueOf(s1.charAt(i));
	        sum += Integer.valueOf(s[i]);
	        } s[i] = String.valueOf(s1.charAt(i)) s[i] s i String.valueOf(s1.charAt(i)) String.valueOf String s1.charAt(i) s1.charAt s1 i sum += Integer.valueOf(s[i]) sum Integer.valueOf(s[i]) Integer.valueOf Integer s[i] s i if(sum == 0){
	        	break;
	        } sum == 0 sum 0 {
	        	break;
	        } break; System.out.println(sum) System.out.println System.out System System.out sum s1 = new String() s1 new String() sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String [] s;
		int sum;
		
		while(true){
			String s1 = sc.next();
			s = new String[s1.length()];
	        sum = 0;
	        
	        for (int i = 0; i < s1.length(); i++) {
	        s[i] = String.valueOf(s1.charAt(i));
	        sum += Integer.valueOf(s[i]);
	        }
	        if(sum == 0){
	        	break;
	        }
	        System.out.println(sum);
	        s1 = new String();
		}
        sc.close();

	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String [] s;
		int sum;
		
		while(true){
			String s1 = sc.next();
			s = new String[s1.length()];
	        sum = 0;
	        
	        for (int i = 0; i < s1.length(); i++) {
	        s[i] = String.valueOf(s1.charAt(i));
	        sum += Integer.valueOf(s[i]);
	        }
	        if(sum == 0){
	        	break;
	        }
	        System.out.println(sum);
	        s1 = new String();
		}
        sc.close();

	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String [] s;
		int sum;
		
		while(true){
			String s1 = sc.next();
			s = new String[s1.length()];
	        sum = 0;
	        
	        for (int i = 0; i < s1.length(); i++) {
	        s[i] = String.valueOf(s1.charAt(i));
	        sum += Integer.valueOf(s[i]);
	        }
	        if(sum == 0){
	        	break;
	        }
	        System.out.println(sum);
	        s1 = new String();
		}
        sc.close();

	}

}
