
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			while(sc.hasNext()) {
				String x = sc.nextLine();
				if(x.equals("0")) {
					break;
				}
				String strA ="";
				int Sum = 0;
				for(int i = 0; i < x.length(); i++) {
					strA = x.substring(i,i+1);
					Sum += Integer.parseInt(strA);
				}
				System.out.println(Sum);
			}
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			while(sc.hasNext()) {
				String x = sc.nextLine();
				if(x.equals("0")) {
					break;
				}
				String strA ="";
				int Sum = 0;
				for(int i = 0; i < x.length(); i++) {
					strA = x.substring(i,i+1);
					Sum += Integer.parseInt(strA);
				}
				System.out.println(Sum);
			}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			while(sc.hasNext()) {
				String x = sc.nextLine();
				if(x.equals("0")) {
					break;
				}
				String strA ="";
				int Sum = 0;
				for(int i = 0; i < x.length(); i++) {
					strA = x.substring(i,i+1);
					Sum += Integer.parseInt(strA);
				}
				System.out.println(Sum);
			}
	} main {
		Scanner sc = new Scanner(System.in);
			while(sc.hasNext()) {
				String x = sc.nextLine();
				if(x.equals("0")) {
					break;
				}
				String strA ="";
				int Sum = 0;
				for(int i = 0; i < x.length(); i++) {
					strA = x.substring(i,i+1);
					Sum += Integer.parseInt(strA);
				}
				System.out.println(Sum);
			}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(sc.hasNext()) {
				String x = sc.nextLine();
				if(x.equals("0")) {
					break;
				}
				String strA ="";
				int Sum = 0;
				for(int i = 0; i < x.length(); i++) {
					strA = x.substring(i,i+1);
					Sum += Integer.parseInt(strA);
				}
				System.out.println(Sum);
			} sc.hasNext() sc.hasNext sc {
				String x = sc.nextLine();
				if(x.equals("0")) {
					break;
				}
				String strA ="";
				int Sum = 0;
				for(int i = 0; i < x.length(); i++) {
					strA = x.substring(i,i+1);
					Sum += Integer.parseInt(strA);
				}
				System.out.println(Sum);
			} String x = sc.nextLine(); x sc.nextLine() sc.nextLine sc if(x.equals("0")) {
					break;
				} x.equals("0") x.equals x "0" {
					break;
				} break; String strA =""; strA "" int Sum = 0; Sum 0 for(int i = 0; i < x.length(); i++) {
					strA = x.substring(i,i+1);
					Sum += Integer.parseInt(strA);
				} int i = 0; int i = 0; i 0 i < x.length() i x.length() x.length x i++ i++ i {
					strA = x.substring(i,i+1);
					Sum += Integer.parseInt(strA);
				} {
					strA = x.substring(i,i+1);
					Sum += Integer.parseInt(strA);
				} strA = x.substring(i,i+1) strA x.substring(i,i+1) x.substring x i i+1 i 1 Sum += Integer.parseInt(strA) Sum Integer.parseInt(strA) Integer.parseInt Integer strA 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 sc = new Scanner(System.in);
			while(sc.hasNext()) {
				String x = sc.nextLine();
				if(x.equals("0")) {
					break;
				}
				String strA ="";
				int Sum = 0;
				for(int i = 0; i < x.length(); i++) {
					strA = x.substring(i,i+1);
					Sum += Integer.parseInt(strA);
				}
				System.out.println(Sum);
			}
	}
} public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			while(sc.hasNext()) {
				String x = sc.nextLine();
				if(x.equals("0")) {
					break;
				}
				String strA ="";
				int Sum = 0;
				for(int i = 0; i < x.length(); i++) {
					strA = x.substring(i,i+1);
					Sum += Integer.parseInt(strA);
				}
				System.out.println(Sum);
			}
	}
} Main

import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			while(sc.hasNext()) {
				String x = sc.nextLine();
				if(x.equals("0")) {
					break;
				}
				String strA ="";
				int Sum = 0;
				for(int i = 0; i < x.length(); i++) {
					strA = x.substring(i,i+1);
					Sum += Integer.parseInt(strA);
				}
				System.out.println(Sum);
			}
	}
}