import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		
		while(true){
			String s = scanner.next();
			int sum = 0;

			for(int i = 0; i < s.length(); i++){
				char ch = s.charAt(i);
				sum += Character.getNumericValue(ch);
			}
			
			if(sum == 0){
			    break;
			}

			System.out.println(sum);
		}
	}
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		
		while(true){
			String s = scanner.next();
			int sum = 0;

			for(int i = 0; i < s.length(); i++){
				char ch = s.charAt(i);
				sum += Character.getNumericValue(ch);
			}
			
			if(sum == 0){
			    break;
			}

			System.out.println(sum);
		}
	}
} Main public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		
		while(true){
			String s = scanner.next();
			int sum = 0;

			for(int i = 0; i < s.length(); i++){
				char ch = s.charAt(i);
				sum += Character.getNumericValue(ch);
			}
			
			if(sum == 0){
			    break;
			}

			System.out.println(sum);
		}
	} main {
		Scanner scanner = new Scanner(System.in);
		
		while(true){
			String s = scanner.next();
			int sum = 0;

			for(int i = 0; i < s.length(); i++){
				char ch = s.charAt(i);
				sum += Character.getNumericValue(ch);
			}
			
			if(sum == 0){
			    break;
			}

			System.out.println(sum);
		}
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while(true){
			String s = scanner.next();
			int sum = 0;

			for(int i = 0; i < s.length(); i++){
				char ch = s.charAt(i);
				sum += Character.getNumericValue(ch);
			}
			
			if(sum == 0){
			    break;
			}

			System.out.println(sum);
		} true {
			String s = scanner.next();
			int sum = 0;

			for(int i = 0; i < s.length(); i++){
				char ch = s.charAt(i);
				sum += Character.getNumericValue(ch);
			}
			
			if(sum == 0){
			    break;
			}

			System.out.println(sum);
		} String s = scanner.next(); s scanner.next() scanner.next scanner int sum = 0; sum 0 for(int i = 0; i < s.length(); i++){
				char ch = s.charAt(i);
				sum += Character.getNumericValue(ch);
			} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
				char ch = s.charAt(i);
				sum += Character.getNumericValue(ch);
			} {
				char ch = s.charAt(i);
				sum += Character.getNumericValue(ch);
			} char ch = s.charAt(i); ch s.charAt(i) s.charAt s i sum += Character.getNumericValue(ch) sum Character.getNumericValue(ch) Character.getNumericValue Character ch if(sum == 0){
			    break;
			} sum == 0 sum 0 {
			    break;
			} break; System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		
		while(true){
			String s = scanner.next();
			int sum = 0;

			for(int i = 0; i < s.length(); i++){
				char ch = s.charAt(i);
				sum += Character.getNumericValue(ch);
			}
			
			if(sum == 0){
			    break;
			}

			System.out.println(sum);
		}
	}
}