import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '0') break;
            int sum = c[0] - '0';
            for(int i = 1,l = c.length;i < l;++i) sum += c[i] - '0';
            System.out.println(sum);
        }

    }

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

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '0') break;
            int sum = c[0] - '0';
            for(int i = 1,l = c.length;i < l;++i) sum += c[i] - '0';
            System.out.println(sum);
        }

    }

} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '0') break;
            int sum = c[0] - '0';
            for(int i = 1,l = c.length;i < l;++i) sum += c[i] - '0';
            System.out.println(sum);
        }

    } main {
        Scanner sc = new Scanner(System.in);
        while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '0') break;
            int sum = c[0] - '0';
            for(int i = 1,l = c.length;i < l;++i) sum += c[i] - '0';
            System.out.println(sum);
        }

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '0') break;
            int sum = c[0] - '0';
            for(int i = 1,l = c.length;i < l;++i) sum += c[i] - '0';
            System.out.println(sum);
        } true {
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '0') break;
            int sum = c[0] - '0';
            for(int i = 1,l = c.length;i < l;++i) sum += c[i] - '0';
            System.out.println(sum);
        } char[] c = sc.nextLine().toCharArray(); c sc.nextLine().toCharArray() sc.nextLine().toCharArray sc.nextLine() sc.nextLine sc if(c[0] == '0') break; c[0] == '0' c[0] c 0 '0' break; int sum = c[0] - '0'; sum c[0] - '0' c[0] c 0 '0' for(int i = 1,l = c.length;i < l;++i) sum += c[i] - '0'; int i = 1,l = c.length; int i = 1 i 1 l = c.length; l c.length c c.length i < l i l ++i ++i i sum += c[i] - '0'; sum += c[i] - '0' sum c[i] - '0' c[i] c i '0' 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){
        Scanner sc = new Scanner(System.in);
        while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '0') break;
            int sum = c[0] - '0';
            for(int i = 1,l = c.length;i < l;++i) sum += c[i] - '0';
            System.out.println(sum);
        }

    }

} public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '0') break;
            int sum = c[0] - '0';
            for(int i = 1,l = c.length;i < l;++i) sum += c[i] - '0';
            System.out.println(sum);
        }

    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '0') break;
            int sum = c[0] - '0';
            for(int i = 1,l = c.length;i < l;++i) sum += c[i] - '0';
            System.out.println(sum);
        }

    }

}