import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long sum = 0;
        while(true) {
            sum = 0;
            String line = br.readLine();
            if(line.length()==1)
                if(Integer.parseInt(line)==0)break;
            for(int i=0;i<line.length();i++){
                sum += Integer.parseInt(String.valueOf(line.charAt(i)));
            }
            System.out.println(sum);
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.*; io.* java import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long sum = 0;
        while(true) {
            sum = 0;
            String line = br.readLine();
            if(line.length()==1)
                if(Integer.parseInt(line)==0)break;
            for(int i=0;i<line.length();i++){
                sum += Integer.parseInt(String.valueOf(line.charAt(i)));
            }
            System.out.println(sum);
        }
    }
} Main public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long sum = 0;
        while(true) {
            sum = 0;
            String line = br.readLine();
            if(line.length()==1)
                if(Integer.parseInt(line)==0)break;
            for(int i=0;i<line.length();i++){
                sum += Integer.parseInt(String.valueOf(line.charAt(i)));
            }
            System.out.println(sum);
        }
    } main {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long sum = 0;
        while(true) {
            sum = 0;
            String line = br.readLine();
            if(line.length()==1)
                if(Integer.parseInt(line)==0)break;
            for(int i=0;i<line.length();i++){
                sum += Integer.parseInt(String.valueOf(line.charAt(i)));
            }
            System.out.println(sum);
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) long sum = 0; sum 0 while(true) {
            sum = 0;
            String line = br.readLine();
            if(line.length()==1)
                if(Integer.parseInt(line)==0)break;
            for(int i=0;i<line.length();i++){
                sum += Integer.parseInt(String.valueOf(line.charAt(i)));
            }
            System.out.println(sum);
        } true {
            sum = 0;
            String line = br.readLine();
            if(line.length()==1)
                if(Integer.parseInt(line)==0)break;
            for(int i=0;i<line.length();i++){
                sum += Integer.parseInt(String.valueOf(line.charAt(i)));
            }
            System.out.println(sum);
        } sum = 0 sum 0 String line = br.readLine(); line br.readLine() br.readLine br if(line.length()==1)
                if(Integer.parseInt(line)==0)break; line.length()==1 line.length() line.length line 1 if(Integer.parseInt(line)==0)break; Integer.parseInt(line)==0 Integer.parseInt(line) Integer.parseInt Integer line 0 break; for(int i=0;i<line.length();i++){
                sum += Integer.parseInt(String.valueOf(line.charAt(i)));
            } int i=0; int i=0; i 0 i<line.length() i line.length() line.length line i++ i++ i {
                sum += Integer.parseInt(String.valueOf(line.charAt(i)));
            } {
                sum += Integer.parseInt(String.valueOf(line.charAt(i)));
            } sum += Integer.parseInt(String.valueOf(line.charAt(i))) sum Integer.parseInt(String.valueOf(line.charAt(i))) Integer.parseInt Integer String.valueOf(line.charAt(i)) String.valueOf String line.charAt(i) line.charAt line i 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 Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long sum = 0;
        while(true) {
            sum = 0;
            String line = br.readLine();
            if(line.length()==1)
                if(Integer.parseInt(line)==0)break;
            for(int i=0;i<line.length();i++){
                sum += Integer.parseInt(String.valueOf(line.charAt(i)));
            }
            System.out.println(sum);
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long sum = 0;
        while(true) {
            sum = 0;
            String line = br.readLine();
            if(line.length()==1)
                if(Integer.parseInt(line)==0)break;
            for(int i=0;i<line.length();i++){
                sum += Integer.parseInt(String.valueOf(line.charAt(i)));
            }
            System.out.println(sum);
        }
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long sum = 0;
        while(true) {
            sum = 0;
            String line = br.readLine();
            if(line.length()==1)
                if(Integer.parseInt(line)==0)break;
            for(int i=0;i<line.length();i++){
                sum += Integer.parseInt(String.valueOf(line.charAt(i)));
            }
            System.out.println(sum);
        }
    }
}