import java.util.*;
public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args) {
 
    while(kbd.hasNext()){
        String n = kbd.next();
        if(!(n.equals("0"))){
        int sum = 0;
        int i=0;
        for(; i<n.length(); i++){
            String a = n.substring(i,i+1);
            //System.out.println(a);
            int b = Integer.parseInt(a);
            //System.out.println(sum+"+"+b);
            sum += b;
        }
            System.out.println(sum);
        }
    }
    }
}        import java.util.*; util.* java public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args) {
 
    while(kbd.hasNext()){
        String n = kbd.next();
        if(!(n.equals("0"))){
        int sum = 0;
        int i=0;
        for(; i<n.length(); i++){
            String a = n.substring(i,i+1);
            //System.out.println(a);
            int b = Integer.parseInt(a);
            //System.out.println(sum+"+"+b);
            sum += b;
        }
            System.out.println(sum);
        }
    }
    }
} Main static Scanner kbd = new Scanner(System.in); kbd new Scanner(System.in) public static void main(String[] args) {
 
    while(kbd.hasNext()){
        String n = kbd.next();
        if(!(n.equals("0"))){
        int sum = 0;
        int i=0;
        for(; i<n.length(); i++){
            String a = n.substring(i,i+1);
            //System.out.println(a);
            int b = Integer.parseInt(a);
            //System.out.println(sum+"+"+b);
            sum += b;
        }
            System.out.println(sum);
        }
    }
    } main {
 
    while(kbd.hasNext()){
        String n = kbd.next();
        if(!(n.equals("0"))){
        int sum = 0;
        int i=0;
        for(; i<n.length(); i++){
            String a = n.substring(i,i+1);
            //System.out.println(a);
            int b = Integer.parseInt(a);
            //System.out.println(sum+"+"+b);
            sum += b;
        }
            System.out.println(sum);
        }
    }
    } while(kbd.hasNext()){
        String n = kbd.next();
        if(!(n.equals("0"))){
        int sum = 0;
        int i=0;
        for(; i<n.length(); i++){
            String a = n.substring(i,i+1);
            //System.out.println(a);
            int b = Integer.parseInt(a);
            //System.out.println(sum+"+"+b);
            sum += b;
        }
            System.out.println(sum);
        }
    } kbd.hasNext() kbd.hasNext kbd {
        String n = kbd.next();
        if(!(n.equals("0"))){
        int sum = 0;
        int i=0;
        for(; i<n.length(); i++){
            String a = n.substring(i,i+1);
            //System.out.println(a);
            int b = Integer.parseInt(a);
            //System.out.println(sum+"+"+b);
            sum += b;
        }
            System.out.println(sum);
        }
    } String n = kbd.next(); n kbd.next() kbd.next kbd if(!(n.equals("0"))){
        int sum = 0;
        int i=0;
        for(; i<n.length(); i++){
            String a = n.substring(i,i+1);
            //System.out.println(a);
            int b = Integer.parseInt(a);
            //System.out.println(sum+"+"+b);
            sum += b;
        }
            System.out.println(sum);
        } !(n.equals("0")) (n.equals("0")) n.equals n "0" {
        int sum = 0;
        int i=0;
        for(; i<n.length(); i++){
            String a = n.substring(i,i+1);
            //System.out.println(a);
            int b = Integer.parseInt(a);
            //System.out.println(sum+"+"+b);
            sum += b;
        }
            System.out.println(sum);
        } int sum = 0; sum 0 int i=0; i 0 for(; i<n.length(); i++){
            String a = n.substring(i,i+1);
            //System.out.println(a);
            int b = Integer.parseInt(a);
            //System.out.println(sum+"+"+b);
            sum += b;
        } ; i<n.length() i n.length() n.length n i++ i++ i {
            String a = n.substring(i,i+1);
            //System.out.println(a);
            int b = Integer.parseInt(a);
            //System.out.println(sum+"+"+b);
            sum += b;
        } {
            String a = n.substring(i,i+1);
            //System.out.println(a);
            int b = Integer.parseInt(a);
            //System.out.println(sum+"+"+b);
            sum += b;
        } String a = n.substring(i,i+1); a n.substring(i,i+1) n.substring n i i+1 i 1 int b = Integer.parseInt(a); b Integer.parseInt(a) Integer.parseInt Integer a sum += b sum b System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args) {
 
    while(kbd.hasNext()){
        String n = kbd.next();
        if(!(n.equals("0"))){
        int sum = 0;
        int i=0;
        for(; i<n.length(); i++){
            String a = n.substring(i,i+1);
            //System.out.println(a);
            int b = Integer.parseInt(a);
            //System.out.println(sum+"+"+b);
            sum += b;
        }
            System.out.println(sum);
        }
    }
    }
} public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args) {
 
    while(kbd.hasNext()){
        String n = kbd.next();
        if(!(n.equals("0"))){
        int sum = 0;
        int i=0;
        for(; i<n.length(); i++){
            String a = n.substring(i,i+1);
            //System.out.println(a);
            int b = Integer.parseInt(a);
            //System.out.println(sum+"+"+b);
            sum += b;
        }
            System.out.println(sum);
        }
    }
    }
} Main
import java.util.*;
public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args) {
 
    while(kbd.hasNext()){
        String n = kbd.next();
        if(!(n.equals("0"))){
        int sum = 0;
        int i=0;
        for(; i<n.length(); i++){
            String a = n.substring(i,i+1);
            //System.out.println(a);
            int b = Integer.parseInt(a);
            //System.out.println(sum+"+"+b);
            sum += b;
        }
            System.out.println(sum);
        }
    }
    }
}       