import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        int digit =0;
        String x=sc.nextLine();
        if(x.equals("0")) break;
        for(int i=0;i<x.length();i++) {
        char c=x.charAt(i);
        digit += c -'0';
        }
        System.out.println(digit);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        int digit =0;
        String x=sc.nextLine();
        if(x.equals("0")) break;
        for(int i=0;i<x.length();i++) {
        char c=x.charAt(i);
        digit += c -'0';
        }
        System.out.println(digit);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        int digit =0;
        String x=sc.nextLine();
        if(x.equals("0")) break;
        for(int i=0;i<x.length();i++) {
        char c=x.charAt(i);
        digit += c -'0';
        }
        System.out.println(digit);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        int digit =0;
        String x=sc.nextLine();
        if(x.equals("0")) break;
        for(int i=0;i<x.length();i++) {
        char c=x.charAt(i);
        digit += c -'0';
        }
        System.out.println(digit);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(sc.hasNextLine()) {
        int digit =0;
        String x=sc.nextLine();
        if(x.equals("0")) break;
        for(int i=0;i<x.length();i++) {
        char c=x.charAt(i);
        digit += c -'0';
        }
        System.out.println(digit);
        } sc.hasNextLine() sc.hasNextLine sc {
        int digit =0;
        String x=sc.nextLine();
        if(x.equals("0")) break;
        for(int i=0;i<x.length();i++) {
        char c=x.charAt(i);
        digit += c -'0';
        }
        System.out.println(digit);
        } int digit =0; digit 0 String x=sc.nextLine(); x sc.nextLine() sc.nextLine sc if(x.equals("0")) break; x.equals("0") x.equals x "0" break; for(int i=0;i<x.length();i++) {
        char c=x.charAt(i);
        digit += c -'0';
        } int i=0; int i=0; i 0 i<x.length() i x.length() x.length x i++ i++ i {
        char c=x.charAt(i);
        digit += c -'0';
        } {
        char c=x.charAt(i);
        digit += c -'0';
        } char c=x.charAt(i); c x.charAt(i) x.charAt x i digit += c -'0' digit c -'0' c '0' System.out.println(digit) System.out.println System.out System System.out digit String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        int digit =0;
        String x=sc.nextLine();
        if(x.equals("0")) break;
        for(int i=0;i<x.length();i++) {
        char c=x.charAt(i);
        digit += c -'0';
        }
        System.out.println(digit);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        int digit =0;
        String x=sc.nextLine();
        if(x.equals("0")) break;
        for(int i=0;i<x.length();i++) {
        char c=x.charAt(i);
        digit += c -'0';
        }
        System.out.println(digit);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        int digit =0;
        String x=sc.nextLine();
        if(x.equals("0")) break;
        for(int i=0;i<x.length();i++) {
        char c=x.charAt(i);
        digit += c -'0';
        }
        System.out.println(digit);
        }
    }
}
