import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sum;
        for (String str = sc.next(); !str.equals("0"); str = sc.next()){
            sum = 0;
            char[] ch = str.toCharArray();
            
            for (int i = 0; i < str.length(); i++){
                sum += ch[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);
        int sum;
        for (String str = sc.next(); !str.equals("0"); str = sc.next()){
            sum = 0;
            char[] ch = str.toCharArray();
            
            for (int i = 0; i < str.length(); i++){
                sum += ch[i] - '0';
            }
            System.out.println(sum);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sum;
        for (String str = sc.next(); !str.equals("0"); str = sc.next()){
            sum = 0;
            char[] ch = str.toCharArray();
            
            for (int i = 0; i < str.length(); i++){
                sum += ch[i] - '0';
            }
            System.out.println(sum);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int sum;
        for (String str = sc.next(); !str.equals("0"); str = sc.next()){
            sum = 0;
            char[] ch = str.toCharArray();
            
            for (int i = 0; i < str.length(); i++){
                sum += ch[i] - '0';
            }
            System.out.println(sum);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int sum; sum for (String str = sc.next(); !str.equals("0"); str = sc.next()){
            sum = 0;
            char[] ch = str.toCharArray();
            
            for (int i = 0; i < str.length(); i++){
                sum += ch[i] - '0';
            }
            System.out.println(sum);
        } String str = sc.next(); String str = sc.next(); str sc.next() sc.next sc !str.equals("0") str.equals("0") str.equals str "0" str = sc.next() str = sc.next() str sc.next() sc.next sc {
            sum = 0;
            char[] ch = str.toCharArray();
            
            for (int i = 0; i < str.length(); i++){
                sum += ch[i] - '0';
            }
            System.out.println(sum);
        } {
            sum = 0;
            char[] ch = str.toCharArray();
            
            for (int i = 0; i < str.length(); i++){
                sum += ch[i] - '0';
            }
            System.out.println(sum);
        } sum = 0 sum 0 char[] ch = str.toCharArray(); ch str.toCharArray() str.toCharArray str for (int i = 0; i < str.length(); i++){
                sum += ch[i] - '0';
            } int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str i++ i++ i {
                sum += ch[i] - '0';
            } {
                sum += ch[i] - '0';
            } sum += ch[i] - '0' sum ch[i] - '0' ch[i] ch 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);
        int sum;
        for (String str = sc.next(); !str.equals("0"); str = sc.next()){
            sum = 0;
            char[] ch = str.toCharArray();
            
            for (int i = 0; i < str.length(); i++){
                sum += ch[i] - '0';
            }
            System.out.println(sum);
        }
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sum;
        for (String str = sc.next(); !str.equals("0"); str = sc.next()){
            sum = 0;
            char[] ch = str.toCharArray();
            
            for (int i = 0; i < str.length(); i++){
                sum += ch[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);
        int sum;
        for (String str = sc.next(); !str.equals("0"); str = sc.next()){
            sum = 0;
            char[] ch = str.toCharArray();
            
            for (int i = 0; i < str.length(); i++){
                sum += ch[i] - '0';
            }
            System.out.println(sum);
        }
    }
}