import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while(true){
            String[] str = sc.nextLine().split("");
            if(Integer.parseInt(str[0]) == 0){
                break;
            }
            int ans = 0;
            for(int i = 0; i < str.length; i++){
                ans += Integer.parseInt(str[i]);
            }
            System.out.println(ans);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while(true){
            String[] str = sc.nextLine().split("");
            if(Integer.parseInt(str[0]) == 0){
                break;
            }
            int ans = 0;
            for(int i = 0; i < str.length; i++){
                ans += Integer.parseInt(str[i]);
            }
            System.out.println(ans);
        }
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while(true){
            String[] str = sc.nextLine().split("");
            if(Integer.parseInt(str[0]) == 0){
                break;
            }
            int ans = 0;
            for(int i = 0; i < str.length; i++){
                ans += Integer.parseInt(str[i]);
            }
            System.out.println(ans);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        while(true){
            String[] str = sc.nextLine().split("");
            if(Integer.parseInt(str[0]) == 0){
                break;
            }
            int ans = 0;
            for(int i = 0; i < str.length; i++){
                ans += Integer.parseInt(str[i]);
            }
            System.out.println(ans);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
            String[] str = sc.nextLine().split("");
            if(Integer.parseInt(str[0]) == 0){
                break;
            }
            int ans = 0;
            for(int i = 0; i < str.length; i++){
                ans += Integer.parseInt(str[i]);
            }
            System.out.println(ans);
        } true {
            String[] str = sc.nextLine().split("");
            if(Integer.parseInt(str[0]) == 0){
                break;
            }
            int ans = 0;
            for(int i = 0; i < str.length; i++){
                ans += Integer.parseInt(str[i]);
            }
            System.out.println(ans);
        } String[] str = sc.nextLine().split(""); str sc.nextLine().split("") sc.nextLine().split sc.nextLine() sc.nextLine sc "" if(Integer.parseInt(str[0]) == 0){
                break;
            } Integer.parseInt(str[0]) == 0 Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 0 {
                break;
            } break; int ans = 0; ans 0 for(int i = 0; i < str.length; i++){
                ans += Integer.parseInt(str[i]);
            } int i = 0; int i = 0; i 0 i < str.length i str.length str str.length i++ i++ i {
                ans += Integer.parseInt(str[i]);
            } {
                ans += Integer.parseInt(str[i]);
            } ans += Integer.parseInt(str[i]) ans Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i 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 Exception {
        Scanner sc = new Scanner(System.in);
        while(true){
            String[] str = sc.nextLine().split("");
            if(Integer.parseInt(str[0]) == 0){
                break;
            }
            int ans = 0;
            for(int i = 0; i < str.length; i++){
                ans += Integer.parseInt(str[i]);
            }
            System.out.println(ans);
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while(true){
            String[] str = sc.nextLine().split("");
            if(Integer.parseInt(str[0]) == 0){
                break;
            }
            int ans = 0;
            for(int i = 0; i < str.length; i++){
                ans += Integer.parseInt(str[i]);
            }
            System.out.println(ans);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while(true){
            String[] str = sc.nextLine().split("");
            if(Integer.parseInt(str[0]) == 0){
                break;
            }
            int ans = 0;
            for(int i = 0; i < str.length; i++){
                ans += Integer.parseInt(str[i]);
            }
            System.out.println(ans);
        }
    }
}