import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int sum;
		String x;
		
		do {
			
			x = scan.nextLine();
					
			if(x.equals("0"))break;
			sum = 0;
			
			for(int i = 0; i < x.length(); i++) {
				char c = x.charAt(i);
				sum += (int)c - 48;
			}
			
			System.out.println(sum);
			
		}while(true);
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int sum;
		String x;
		
		do {
			
			x = scan.nextLine();
					
			if(x.equals("0"))break;
			sum = 0;
			
			for(int i = 0; i < x.length(); i++) {
				char c = x.charAt(i);
				sum += (int)c - 48;
			}
			
			System.out.println(sum);
			
		}while(true);
	}
} Main public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int sum;
		String x;
		
		do {
			
			x = scan.nextLine();
					
			if(x.equals("0"))break;
			sum = 0;
			
			for(int i = 0; i < x.length(); i++) {
				char c = x.charAt(i);
				sum += (int)c - 48;
			}
			
			System.out.println(sum);
			
		}while(true);
	} main {
		Scanner scan = new Scanner(System.in);
		int sum;
		String x;
		
		do {
			
			x = scan.nextLine();
					
			if(x.equals("0"))break;
			sum = 0;
			
			for(int i = 0; i < x.length(); i++) {
				char c = x.charAt(i);
				sum += (int)c - 48;
			}
			
			System.out.println(sum);
			
		}while(true);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int sum; sum String x; x do {
			
			x = scan.nextLine();
					
			if(x.equals("0"))break;
			sum = 0;
			
			for(int i = 0; i < x.length(); i++) {
				char c = x.charAt(i);
				sum += (int)c - 48;
			}
			
			System.out.println(sum);
			
		}while(true); true {
			
			x = scan.nextLine();
					
			if(x.equals("0"))break;
			sum = 0;
			
			for(int i = 0; i < x.length(); i++) {
				char c = x.charAt(i);
				sum += (int)c - 48;
			}
			
			System.out.println(sum);
			
		} x = scan.nextLine() x scan.nextLine() scan.nextLine scan if(x.equals("0"))break; x.equals("0") x.equals x "0" break; sum = 0 sum 0 for(int i = 0; i < x.length(); i++) {
				char c = x.charAt(i);
				sum += (int)c - 48;
			} int i = 0; int i = 0; i 0 i < x.length() i x.length() x.length x i++ i++ i {
				char c = x.charAt(i);
				sum += (int)c - 48;
			} {
				char c = x.charAt(i);
				sum += (int)c - 48;
			} char c = x.charAt(i); c x.charAt(i) x.charAt x i sum += (int)c - 48 sum (int)c - 48 (int)c 48 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 sum;
		String x;
		
		do {
			
			x = scan.nextLine();
					
			if(x.equals("0"))break;
			sum = 0;
			
			for(int i = 0; i < x.length(); i++) {
				char c = x.charAt(i);
				sum += (int)c - 48;
			}
			
			System.out.println(sum);
			
		}while(true);
	}
} public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int sum;
		String x;
		
		do {
			
			x = scan.nextLine();
					
			if(x.equals("0"))break;
			sum = 0;
			
			for(int i = 0; i < x.length(); i++) {
				char c = x.charAt(i);
				sum += (int)c - 48;
			}
			
			System.out.println(sum);
			
		}while(true);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int sum;
		String x;
		
		do {
			
			x = scan.nextLine();
					
			if(x.equals("0"))break;
			sum = 0;
			
			for(int i = 0; i < x.length(); i++) {
				char c = x.charAt(i);
				sum += (int)c - 48;
			}
			
			System.out.println(sum);
			
		}while(true);
	}
}

