import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String s = sc.next();
            if (s.equals("0")) {
                break;
            }
            System.out.println(digitSum(s));
        }
    }

    private static int digitSum(String num) {
        int sum = 0;
        for (int i = 0; i < num.length(); i++) {
            sum += Integer.parseInt(String.valueOf(num.charAt(i)));
        }
        return 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) {
            String s = sc.next();
            if (s.equals("0")) {
                break;
            }
            System.out.println(digitSum(s));
        }
    }

    private static int digitSum(String num) {
        int sum = 0;
        for (int i = 0; i < num.length(); i++) {
            sum += Integer.parseInt(String.valueOf(num.charAt(i)));
        }
        return sum;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String s = sc.next();
            if (s.equals("0")) {
                break;
            }
            System.out.println(digitSum(s));
        }
    } main {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String s = sc.next();
            if (s.equals("0")) {
                break;
            }
            System.out.println(digitSum(s));
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
            String s = sc.next();
            if (s.equals("0")) {
                break;
            }
            System.out.println(digitSum(s));
        } true {
            String s = sc.next();
            if (s.equals("0")) {
                break;
            }
            System.out.println(digitSum(s));
        } String s = sc.next(); s sc.next() sc.next sc if (s.equals("0")) {
                break;
            } s.equals("0") s.equals s "0" {
                break;
            } break; System.out.println(digitSum(s)) System.out.println System.out System System.out digitSum(s) digitSum s String[] args args private static int digitSum(String num) {
        int sum = 0;
        for (int i = 0; i < num.length(); i++) {
            sum += Integer.parseInt(String.valueOf(num.charAt(i)));
        }
        return sum;
    } digitSum {
        int sum = 0;
        for (int i = 0; i < num.length(); i++) {
            sum += Integer.parseInt(String.valueOf(num.charAt(i)));
        }
        return sum;
    } int sum = 0; sum 0 for (int i = 0; i < num.length(); i++) {
            sum += Integer.parseInt(String.valueOf(num.charAt(i)));
        } int i = 0; int i = 0; i 0 i < num.length() i num.length() num.length num i++ i++ i {
            sum += Integer.parseInt(String.valueOf(num.charAt(i)));
        } {
            sum += Integer.parseInt(String.valueOf(num.charAt(i)));
        } sum += Integer.parseInt(String.valueOf(num.charAt(i))) sum Integer.parseInt(String.valueOf(num.charAt(i))) Integer.parseInt Integer String.valueOf(num.charAt(i)) String.valueOf String num.charAt(i) num.charAt num i return sum; sum String num num public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String s = sc.next();
            if (s.equals("0")) {
                break;
            }
            System.out.println(digitSum(s));
        }
    }

    private static int digitSum(String num) {
        int sum = 0;
        for (int i = 0; i < num.length(); i++) {
            sum += Integer.parseInt(String.valueOf(num.charAt(i)));
        }
        return sum;
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String s = sc.next();
            if (s.equals("0")) {
                break;
            }
            System.out.println(digitSum(s));
        }
    }

    private static int digitSum(String num) {
        int sum = 0;
        for (int i = 0; i < num.length(); i++) {
            sum += Integer.parseInt(String.valueOf(num.charAt(i)));
        }
        return sum;
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String s = sc.next();
            if (s.equals("0")) {
                break;
            }
            System.out.println(digitSum(s));
        }
    }

    private static int digitSum(String num) {
        int sum = 0;
        for (int i = 0; i < num.length(); i++) {
            sum += Integer.parseInt(String.valueOf(num.charAt(i)));
        }
        return sum;
    }
}