import java.io.*;

class Main{
    public static void main(String[] args) throws IOException
    {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);

        int sum;
        char c;
        while(true){
            String line = br.readLine();
            if(line.length() == 1 && line.charAt(0) == '0'){ break; }
            sum = 0;
            for(int i = 0; i < line.length(); i++){
                c = line.charAt(i);
                sum += (c - 48);
            }
            System.out.println(sum);
        }
    }
} import java.io.*; io.* java class Main{
    public static void main(String[] args) throws IOException
    {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);

        int sum;
        char c;
        while(true){
            String line = br.readLine();
            if(line.length() == 1 && line.charAt(0) == '0'){ break; }
            sum = 0;
            for(int i = 0; i < line.length(); i++){
                c = line.charAt(i);
                sum += (c - 48);
            }
            System.out.println(sum);
        }
    }
} Main public static void main(String[] args) throws IOException
    {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);

        int sum;
        char c;
        while(true){
            String line = br.readLine();
            if(line.length() == 1 && line.charAt(0) == '0'){ break; }
            sum = 0;
            for(int i = 0; i < line.length(); i++){
                c = line.charAt(i);
                sum += (c - 48);
            }
            System.out.println(sum);
        }
    } main {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);

        int sum;
        char c;
        while(true){
            String line = br.readLine();
            if(line.length() == 1 && line.charAt(0) == '0'){ break; }
            sum = 0;
            for(int i = 0; i < line.length(); i++){
                c = line.charAt(i);
                sum += (c - 48);
            }
            System.out.println(sum);
        }
    } InputStreamReader is = new InputStreamReader(System.in); is new InputStreamReader(System.in) BufferedReader br = new BufferedReader(is); br new BufferedReader(is) int sum; sum char c; c while(true){
            String line = br.readLine();
            if(line.length() == 1 && line.charAt(0) == '0'){ break; }
            sum = 0;
            for(int i = 0; i < line.length(); i++){
                c = line.charAt(i);
                sum += (c - 48);
            }
            System.out.println(sum);
        } true {
            String line = br.readLine();
            if(line.length() == 1 && line.charAt(0) == '0'){ break; }
            sum = 0;
            for(int i = 0; i < line.length(); i++){
                c = line.charAt(i);
                sum += (c - 48);
            }
            System.out.println(sum);
        } String line = br.readLine(); line br.readLine() br.readLine br if(line.length() == 1 && line.charAt(0) == '0'){ break; } line.length() == 1 && line.charAt(0) == '0' line.length() == 1 line.length() line.length line 1 line.charAt(0) == '0' line.charAt(0) line.charAt line 0 '0' { break; } break; sum = 0 sum 0 for(int i = 0; i < line.length(); i++){
                c = line.charAt(i);
                sum += (c - 48);
            } int i = 0; int i = 0; i 0 i < line.length() i line.length() line.length line i++ i++ i {
                c = line.charAt(i);
                sum += (c - 48);
            } {
                c = line.charAt(i);
                sum += (c - 48);
            } c = line.charAt(i) c line.charAt(i) line.charAt line i sum += (c - 48) sum (c - 48) c 48 System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException
    {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);

        int sum;
        char c;
        while(true){
            String line = br.readLine();
            if(line.length() == 1 && line.charAt(0) == '0'){ break; }
            sum = 0;
            for(int i = 0; i < line.length(); i++){
                c = line.charAt(i);
                sum += (c - 48);
            }
            System.out.println(sum);
        }
    }
}
