import java.util.Scanner;
import java.util.function.Function;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    Scanner sc = new Scanner(System.in);

    void solve() {
        String str;
        while (true) {
            str = sc.nextLine();
            if (isFin(str))
                break;
            System.out.println(digitSum(str));
        }

    }

    int digitSum(String str) {
        int sum = 0;
        String[] strArr = str.split("");
        for (int i = 0; i < str.length(); ++i) {
            sum += Integer.parseInt(strArr[i]);
        }
        return sum;
    }

    boolean isFin(String str) {
        return str.equals("0");
    }
}



 import java.util.Scanner; Scanner java.util import java.util.function.Function; Function java.util.function public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    Scanner sc = new Scanner(System.in);

    void solve() {
        String str;
        while (true) {
            str = sc.nextLine();
            if (isFin(str))
                break;
            System.out.println(digitSum(str));
        }

    }

    int digitSum(String str) {
        int sum = 0;
        String[] strArr = str.split("");
        for (int i = 0; i < str.length(); ++i) {
            sum += Integer.parseInt(strArr[i]);
        }
        return sum;
    }

    boolean isFin(String str) {
        return str.equals("0");
    }
} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
        new Main().solve();
    } main {
        new Main().solve();
    } new Main().solve() new Main().solve new Main() String[] args args void solve() {
        String str;
        while (true) {
            str = sc.nextLine();
            if (isFin(str))
                break;
            System.out.println(digitSum(str));
        }

    } solve {
        String str;
        while (true) {
            str = sc.nextLine();
            if (isFin(str))
                break;
            System.out.println(digitSum(str));
        }

    } String str; str while (true) {
            str = sc.nextLine();
            if (isFin(str))
                break;
            System.out.println(digitSum(str));
        } true {
            str = sc.nextLine();
            if (isFin(str))
                break;
            System.out.println(digitSum(str));
        } str = sc.nextLine() str sc.nextLine() sc.nextLine sc if (isFin(str))
                break; isFin(str) isFin str break; System.out.println(digitSum(str)) System.out.println System.out System System.out digitSum(str) digitSum str int digitSum(String str) {
        int sum = 0;
        String[] strArr = str.split("");
        for (int i = 0; i < str.length(); ++i) {
            sum += Integer.parseInt(strArr[i]);
        }
        return sum;
    } digitSum {
        int sum = 0;
        String[] strArr = str.split("");
        for (int i = 0; i < str.length(); ++i) {
            sum += Integer.parseInt(strArr[i]);
        }
        return sum;
    } int sum = 0; sum 0 String[] strArr = str.split(""); strArr str.split("") str.split str "" for (int i = 0; i < str.length(); ++i) {
            sum += Integer.parseInt(strArr[i]);
        } int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str ++i ++i i {
            sum += Integer.parseInt(strArr[i]);
        } {
            sum += Integer.parseInt(strArr[i]);
        } sum += Integer.parseInt(strArr[i]) sum Integer.parseInt(strArr[i]) Integer.parseInt Integer strArr[i] strArr i return sum; sum String str str boolean isFin(String str) {
        return str.equals("0");
    } isFin {
        return str.equals("0");
    } return str.equals("0"); str.equals("0") str.equals str "0" String str str public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    Scanner sc = new Scanner(System.in);

    void solve() {
        String str;
        while (true) {
            str = sc.nextLine();
            if (isFin(str))
                break;
            System.out.println(digitSum(str));
        }

    }

    int digitSum(String str) {
        int sum = 0;
        String[] strArr = str.split("");
        for (int i = 0; i < str.length(); ++i) {
            sum += Integer.parseInt(strArr[i]);
        }
        return sum;
    }

    boolean isFin(String str) {
        return str.equals("0");
    }
} public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    Scanner sc = new Scanner(System.in);

    void solve() {
        String str;
        while (true) {
            str = sc.nextLine();
            if (isFin(str))
                break;
            System.out.println(digitSum(str));
        }

    }

    int digitSum(String str) {
        int sum = 0;
        String[] strArr = str.split("");
        for (int i = 0; i < str.length(); ++i) {
            sum += Integer.parseInt(strArr[i]);
        }
        return sum;
    }

    boolean isFin(String str) {
        return str.equals("0");
    }
} Main
import java.util.Scanner;
import java.util.function.Function;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    Scanner sc = new Scanner(System.in);

    void solve() {
        String str;
        while (true) {
            str = sc.nextLine();
            if (isFin(str))
                break;
            System.out.println(digitSum(str));
        }

    }

    int digitSum(String str) {
        int sum = 0;
        String[] strArr = str.split("");
        for (int i = 0; i < str.length(); ++i) {
            sum += Integer.parseInt(strArr[i]);
        }
        return sum;
    }

    boolean isFin(String str) {
        return str.equals("0");
    }
}




