import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n,i,sum;
        String str;
        while(true) {
        	sum=0;
        	str=scan.next();
        	n=str.length();
        	for(i=0;i<n;i++) {
        		sum+=Character.getNumericValue(str.charAt(i));
        	}
        	if(sum==0) {
        		break;
        	}
        	else {
        		System.out.println(sum);
        	}
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n,i,sum;
        String str;
        while(true) {
        	sum=0;
        	str=scan.next();
        	n=str.length();
        	for(i=0;i<n;i++) {
        		sum+=Character.getNumericValue(str.charAt(i));
        	}
        	if(sum==0) {
        		break;
        	}
        	else {
        		System.out.println(sum);
        	}
        }
    }
} Main public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n,i,sum;
        String str;
        while(true) {
        	sum=0;
        	str=scan.next();
        	n=str.length();
        	for(i=0;i<n;i++) {
        		sum+=Character.getNumericValue(str.charAt(i));
        	}
        	if(sum==0) {
        		break;
        	}
        	else {
        		System.out.println(sum);
        	}
        }
    } main {
        Scanner scan=new Scanner(System.in);
        int n,i,sum;
        String str;
        while(true) {
        	sum=0;
        	str=scan.next();
        	n=str.length();
        	for(i=0;i<n;i++) {
        		sum+=Character.getNumericValue(str.charAt(i));
        	}
        	if(sum==0) {
        		break;
        	}
        	else {
        		System.out.println(sum);
        	}
        }
    } Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int n n i i sum; sum String str; str while(true) {
        	sum=0;
        	str=scan.next();
        	n=str.length();
        	for(i=0;i<n;i++) {
        		sum+=Character.getNumericValue(str.charAt(i));
        	}
        	if(sum==0) {
        		break;
        	}
        	else {
        		System.out.println(sum);
        	}
        } true {
        	sum=0;
        	str=scan.next();
        	n=str.length();
        	for(i=0;i<n;i++) {
        		sum+=Character.getNumericValue(str.charAt(i));
        	}
        	if(sum==0) {
        		break;
        	}
        	else {
        		System.out.println(sum);
        	}
        } sum=0 sum 0 str=scan.next() str scan.next() scan.next scan n=str.length() n str.length() str.length str for(i=0;i<n;i++) {
        		sum+=Character.getNumericValue(str.charAt(i));
        	} i=0; i=0 i 0 i<n i n i++ i++ i {
        		sum+=Character.getNumericValue(str.charAt(i));
        	} {
        		sum+=Character.getNumericValue(str.charAt(i));
        	} sum+=Character.getNumericValue(str.charAt(i)) sum Character.getNumericValue(str.charAt(i)) Character.getNumericValue Character str.charAt(i) str.charAt str i if(sum==0) {
        		break;
        	}
        	else {
        		System.out.println(sum);
        	} sum==0 sum 0 {
        		break;
        	} break; {
        		System.out.println(sum);
        	} System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n,i,sum;
        String str;
        while(true) {
        	sum=0;
        	str=scan.next();
        	n=str.length();
        	for(i=0;i<n;i++) {
        		sum+=Character.getNumericValue(str.charAt(i));
        	}
        	if(sum==0) {
        		break;
        	}
        	else {
        		System.out.println(sum);
        	}
        }
    }
} public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n,i,sum;
        String str;
        while(true) {
        	sum=0;
        	str=scan.next();
        	n=str.length();
        	for(i=0;i<n;i++) {
        		sum+=Character.getNumericValue(str.charAt(i));
        	}
        	if(sum==0) {
        		break;
        	}
        	else {
        		System.out.println(sum);
        	}
        }
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n,i,sum;
        String str;
        while(true) {
        	sum=0;
        	str=scan.next();
        	n=str.length();
        	for(i=0;i<n;i++) {
        		sum+=Character.getNumericValue(str.charAt(i));
        	}
        	if(sum==0) {
        		break;
        	}
        	else {
        		System.out.println(sum);
        	}
        }
    }
}
