
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        while(true){
            String s=scanner.next();
            String[] strings=s.split("");
            if(strings[0].equals("0")){
                return;
            }
            long result=0;
            for(int i=0;i<strings.length;i++){
                int c=Integer.parseInt(strings[i]);
                result+=c;
            }
            System.out.println(result);

        }
    }

}
 import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        while(true){
            String s=scanner.next();
            String[] strings=s.split("");
            if(strings[0].equals("0")){
                return;
            }
            long result=0;
            for(int i=0;i<strings.length;i++){
                int c=Integer.parseInt(strings[i]);
                result+=c;
            }
            System.out.println(result);

        }
    }

} Main public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        while(true){
            String s=scanner.next();
            String[] strings=s.split("");
            if(strings[0].equals("0")){
                return;
            }
            long result=0;
            for(int i=0;i<strings.length;i++){
                int c=Integer.parseInt(strings[i]);
                result+=c;
            }
            System.out.println(result);

        }
    } main {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        while(true){
            String s=scanner.next();
            String[] strings=s.split("");
            if(strings[0].equals("0")){
                return;
            }
            long result=0;
            for(int i=0;i<strings.length;i++){
                int c=Integer.parseInt(strings[i]);
                result+=c;
            }
            System.out.println(result);

        }
    } Scanner scanner=new Scanner(System.in); scanner new Scanner(System.in) while(true){
            String s=scanner.next();
            String[] strings=s.split("");
            if(strings[0].equals("0")){
                return;
            }
            long result=0;
            for(int i=0;i<strings.length;i++){
                int c=Integer.parseInt(strings[i]);
                result+=c;
            }
            System.out.println(result);

        } true {
            String s=scanner.next();
            String[] strings=s.split("");
            if(strings[0].equals("0")){
                return;
            }
            long result=0;
            for(int i=0;i<strings.length;i++){
                int c=Integer.parseInt(strings[i]);
                result+=c;
            }
            System.out.println(result);

        } String s=scanner.next(); s scanner.next() scanner.next scanner String[] strings=s.split(""); strings s.split("") s.split s "" if(strings[0].equals("0")){
                return;
            } strings[0].equals("0") strings[0].equals strings[0] strings 0 "0" {
                return;
            } return; long result=0; result 0 for(int i=0;i<strings.length;i++){
                int c=Integer.parseInt(strings[i]);
                result+=c;
            } int i=0; int i=0; i 0 i<strings.length i strings.length strings strings.length i++ i++ i {
                int c=Integer.parseInt(strings[i]);
                result+=c;
            } {
                int c=Integer.parseInt(strings[i]);
                result+=c;
            } int c=Integer.parseInt(strings[i]); c Integer.parseInt(strings[i]) Integer.parseInt Integer strings[i] strings i result+=c result c System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        while(true){
            String s=scanner.next();
            String[] strings=s.split("");
            if(strings[0].equals("0")){
                return;
            }
            long result=0;
            for(int i=0;i<strings.length;i++){
                int c=Integer.parseInt(strings[i]);
                result+=c;
            }
            System.out.println(result);

        }
    }

} public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        while(true){
            String s=scanner.next();
            String[] strings=s.split("");
            if(strings[0].equals("0")){
                return;
            }
            long result=0;
            for(int i=0;i<strings.length;i++){
                int c=Integer.parseInt(strings[i]);
                result+=c;
            }
            System.out.println(result);

        }
    }

} Main

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        while(true){
            String s=scanner.next();
            String[] strings=s.split("");
            if(strings[0].equals("0")){
                return;
            }
            long result=0;
            for(int i=0;i<strings.length;i++){
                int c=Integer.parseInt(strings[i]);
                result+=c;
            }
            System.out.println(result);

        }
    }

}

