import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        StringBuilder sb = new StringBuilder();
        int result;
        while(true){
            str = br.readLine().split("");
            if(str[0].equals("0")) break;
            result = 0;
            for(String str1 : str){
                result += Integer.parseInt(str1);
            }
            sb.append(result).append("\n");
        }
        System.out.print(sb);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        StringBuilder sb = new StringBuilder();
        int result;
        while(true){
            str = br.readLine().split("");
            if(str[0].equals("0")) break;
            result = 0;
            for(String str1 : str){
                result += Integer.parseInt(str1);
            }
            sb.append(result).append("\n");
        }
        System.out.print(sb);
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        StringBuilder sb = new StringBuilder();
        int result;
        while(true){
            str = br.readLine().split("");
            if(str[0].equals("0")) break;
            result = 0;
            for(String str1 : str){
                result += Integer.parseInt(str1);
            }
            sb.append(result).append("\n");
        }
        System.out.print(sb);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        StringBuilder sb = new StringBuilder();
        int result;
        while(true){
            str = br.readLine().split("");
            if(str[0].equals("0")) break;
            result = 0;
            for(String str1 : str){
                result += Integer.parseInt(str1);
            }
            sb.append(result).append("\n");
        }
        System.out.print(sb);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str[]; str StringBuilder sb = new StringBuilder(); sb new StringBuilder() int result; result while(true){
            str = br.readLine().split("");
            if(str[0].equals("0")) break;
            result = 0;
            for(String str1 : str){
                result += Integer.parseInt(str1);
            }
            sb.append(result).append("\n");
        } true {
            str = br.readLine().split("");
            if(str[0].equals("0")) break;
            result = 0;
            for(String str1 : str){
                result += Integer.parseInt(str1);
            }
            sb.append(result).append("\n");
        } str = br.readLine().split("") str br.readLine().split("") br.readLine().split br.readLine() br.readLine br "" if(str[0].equals("0")) break; str[0].equals("0") str[0].equals str[0] str 0 "0" break; result = 0 result 0 for(String str1 : str){
                result += Integer.parseInt(str1);
            } String str1 str {
                result += Integer.parseInt(str1);
            } {
                result += Integer.parseInt(str1);
            } result += Integer.parseInt(str1) result Integer.parseInt(str1) Integer.parseInt Integer str1 sb.append(result).append("\n") sb.append(result).append sb.append(result) sb.append sb result "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        StringBuilder sb = new StringBuilder();
        int result;
        while(true){
            str = br.readLine().split("");
            if(str[0].equals("0")) break;
            result = 0;
            for(String str1 : str){
                result += Integer.parseInt(str1);
            }
            sb.append(result).append("\n");
        }
        System.out.print(sb);
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        StringBuilder sb = new StringBuilder();
        int result;
        while(true){
            str = br.readLine().split("");
            if(str[0].equals("0")) break;
            result = 0;
            for(String str1 : str){
                result += Integer.parseInt(str1);
            }
            sb.append(result).append("\n");
        }
        System.out.print(sb);
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        StringBuilder sb = new StringBuilder();
        int result;
        while(true){
            str = br.readLine().split("");
            if(str[0].equals("0")) break;
            result = 0;
            for(String str1 : str){
                result += Integer.parseInt(str1);
            }
            sb.append(result).append("\n");
        }
        System.out.print(sb);
    }
}