import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String n = scan.nextLine();
        while (!n.equals("0")){
            int sum = 0;
            for(int x = 0; x < n.length();x++) {
                sum = sum + Integer.parseInt(Character.toString(n.charAt(x)));
            }
            System.out.println(sum);
            n = scan.nextLine();
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String n = scan.nextLine();
        while (!n.equals("0")){
            int sum = 0;
            for(int x = 0; x < n.length();x++) {
                sum = sum + Integer.parseInt(Character.toString(n.charAt(x)));
            }
            System.out.println(sum);
            n = scan.nextLine();
        }
    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String n = scan.nextLine();
        while (!n.equals("0")){
            int sum = 0;
            for(int x = 0; x < n.length();x++) {
                sum = sum + Integer.parseInt(Character.toString(n.charAt(x)));
            }
            System.out.println(sum);
            n = scan.nextLine();
        }
    } main {
        Scanner scan = new Scanner(System.in);
        String n = scan.nextLine();
        while (!n.equals("0")){
            int sum = 0;
            for(int x = 0; x < n.length();x++) {
                sum = sum + Integer.parseInt(Character.toString(n.charAt(x)));
            }
            System.out.println(sum);
            n = scan.nextLine();
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String n = scan.nextLine(); n scan.nextLine() scan.nextLine scan while (!n.equals("0")){
            int sum = 0;
            for(int x = 0; x < n.length();x++) {
                sum = sum + Integer.parseInt(Character.toString(n.charAt(x)));
            }
            System.out.println(sum);
            n = scan.nextLine();
        } !n.equals("0") n.equals("0") n.equals n "0" {
            int sum = 0;
            for(int x = 0; x < n.length();x++) {
                sum = sum + Integer.parseInt(Character.toString(n.charAt(x)));
            }
            System.out.println(sum);
            n = scan.nextLine();
        } int sum = 0; sum 0 for(int x = 0; x < n.length();x++) {
                sum = sum + Integer.parseInt(Character.toString(n.charAt(x)));
            } int x = 0; int x = 0; x 0 x < n.length() x n.length() n.length n x++ x++ x {
                sum = sum + Integer.parseInt(Character.toString(n.charAt(x)));
            } {
                sum = sum + Integer.parseInt(Character.toString(n.charAt(x)));
            } sum = sum + Integer.parseInt(Character.toString(n.charAt(x))) sum sum + Integer.parseInt(Character.toString(n.charAt(x))) sum Integer.parseInt(Character.toString(n.charAt(x))) Integer.parseInt Integer Character.toString(n.charAt(x)) Character.toString Character n.charAt(x) n.charAt n x System.out.println(sum) System.out.println System.out System System.out sum n = scan.nextLine() n scan.nextLine() scan.nextLine scan String[] args args public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String n = scan.nextLine();
        while (!n.equals("0")){
            int sum = 0;
            for(int x = 0; x < n.length();x++) {
                sum = sum + Integer.parseInt(Character.toString(n.charAt(x)));
            }
            System.out.println(sum);
            n = scan.nextLine();
        }
    }
} public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String n = scan.nextLine();
        while (!n.equals("0")){
            int sum = 0;
            for(int x = 0; x < n.length();x++) {
                sum = sum + Integer.parseInt(Character.toString(n.charAt(x)));
            }
            System.out.println(sum);
            n = scan.nextLine();
        }
    }
} Main
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String n = scan.nextLine();
        while (!n.equals("0")){
            int sum = 0;
            for(int x = 0; x < n.length();x++) {
                sum = sum + Integer.parseInt(Character.toString(n.charAt(x)));
            }
            System.out.println(sum);
            n = scan.nextLine();
        }
    }
}
