import java.util.Scanner;

public class Main {


		public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		while(true){
			int num = 0;
			String moji = scan.next();
			int moji_len = moji.length();
			//??§????????¨?°????????????\??????????????????
			for(int cnt_len = 0; cnt_len < moji_len; cnt_len++){
				char moji_one = moji.charAt(cnt_len);
				String moji_str = String.valueOf(moji_one);
				int moji_int = Integer.decode(moji_str);
				num += moji_int;
			}
			//0?????\???????????????????????¨?????????????????????
			if(num == 0)
				break;
			else
				System.out.println(num);
		}
		//????§????
		scan.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {


		public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		while(true){
			int num = 0;
			String moji = scan.next();
			int moji_len = moji.length();
			//??§????????¨?°????????????\??????????????????
			for(int cnt_len = 0; cnt_len < moji_len; cnt_len++){
				char moji_one = moji.charAt(cnt_len);
				String moji_str = String.valueOf(moji_one);
				int moji_int = Integer.decode(moji_str);
				num += moji_int;
			}
			//0?????\???????????????????????¨?????????????????????
			if(num == 0)
				break;
			else
				System.out.println(num);
		}
		//????§????
		scan.close();
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		while(true){
			int num = 0;
			String moji = scan.next();
			int moji_len = moji.length();
			//??§????????¨?°????????????\??????????????????
			for(int cnt_len = 0; cnt_len < moji_len; cnt_len++){
				char moji_one = moji.charAt(cnt_len);
				String moji_str = String.valueOf(moji_one);
				int moji_int = Integer.decode(moji_str);
				num += moji_int;
			}
			//0?????\???????????????????????¨?????????????????????
			if(num == 0)
				break;
			else
				System.out.println(num);
		}
		//????§????
		scan.close();
	} main {
		Scanner scan = new Scanner(System.in);

		while(true){
			int num = 0;
			String moji = scan.next();
			int moji_len = moji.length();
			//??§????????¨?°????????????\??????????????????
			for(int cnt_len = 0; cnt_len < moji_len; cnt_len++){
				char moji_one = moji.charAt(cnt_len);
				String moji_str = String.valueOf(moji_one);
				int moji_int = Integer.decode(moji_str);
				num += moji_int;
			}
			//0?????\???????????????????????¨?????????????????????
			if(num == 0)
				break;
			else
				System.out.println(num);
		}
		//????§????
		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while(true){
			int num = 0;
			String moji = scan.next();
			int moji_len = moji.length();
			//??§????????¨?°????????????\??????????????????
			for(int cnt_len = 0; cnt_len < moji_len; cnt_len++){
				char moji_one = moji.charAt(cnt_len);
				String moji_str = String.valueOf(moji_one);
				int moji_int = Integer.decode(moji_str);
				num += moji_int;
			}
			//0?????\???????????????????????¨?????????????????????
			if(num == 0)
				break;
			else
				System.out.println(num);
		} true {
			int num = 0;
			String moji = scan.next();
			int moji_len = moji.length();
			//??§????????¨?°????????????\??????????????????
			for(int cnt_len = 0; cnt_len < moji_len; cnt_len++){
				char moji_one = moji.charAt(cnt_len);
				String moji_str = String.valueOf(moji_one);
				int moji_int = Integer.decode(moji_str);
				num += moji_int;
			}
			//0?????\???????????????????????¨?????????????????????
			if(num == 0)
				break;
			else
				System.out.println(num);
		} int num = 0; num 0 String moji = scan.next(); moji scan.next() scan.next scan int moji_len = moji.length(); moji_len moji.length() moji.length moji for(int cnt_len = 0; cnt_len < moji_len; cnt_len++){
				char moji_one = moji.charAt(cnt_len);
				String moji_str = String.valueOf(moji_one);
				int moji_int = Integer.decode(moji_str);
				num += moji_int;
			} int cnt_len = 0; int cnt_len = 0; cnt_len 0 cnt_len < moji_len cnt_len moji_len cnt_len++ cnt_len++ cnt_len {
				char moji_one = moji.charAt(cnt_len);
				String moji_str = String.valueOf(moji_one);
				int moji_int = Integer.decode(moji_str);
				num += moji_int;
			} {
				char moji_one = moji.charAt(cnt_len);
				String moji_str = String.valueOf(moji_one);
				int moji_int = Integer.decode(moji_str);
				num += moji_int;
			} char moji_one = moji.charAt(cnt_len); moji_one moji.charAt(cnt_len) moji.charAt moji cnt_len String moji_str = String.valueOf(moji_one); moji_str String.valueOf(moji_one) String.valueOf String moji_one int moji_int = Integer.decode(moji_str); moji_int Integer.decode(moji_str) Integer.decode Integer moji_str num += moji_int num moji_int if(num == 0)
				break;
			else
				System.out.println(num); num == 0 num 0 break; System.out.println(num) System.out.println System.out System System.out num scan.close() scan.close scan String[] args args public class Main {


		public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		while(true){
			int num = 0;
			String moji = scan.next();
			int moji_len = moji.length();
			//??§????????¨?°????????????\??????????????????
			for(int cnt_len = 0; cnt_len < moji_len; cnt_len++){
				char moji_one = moji.charAt(cnt_len);
				String moji_str = String.valueOf(moji_one);
				int moji_int = Integer.decode(moji_str);
				num += moji_int;
			}
			//0?????\???????????????????????¨?????????????????????
			if(num == 0)
				break;
			else
				System.out.println(num);
		}
		//????§????
		scan.close();
	}
} public class Main {


		public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		while(true){
			int num = 0;
			String moji = scan.next();
			int moji_len = moji.length();
			//??§????????¨?°????????????\??????????????????
			for(int cnt_len = 0; cnt_len < moji_len; cnt_len++){
				char moji_one = moji.charAt(cnt_len);
				String moji_str = String.valueOf(moji_one);
				int moji_int = Integer.decode(moji_str);
				num += moji_int;
			}
			//0?????\???????????????????????¨?????????????????????
			if(num == 0)
				break;
			else
				System.out.println(num);
		}
		//????§????
		scan.close();
	}
} Main
import java.util.Scanner;

public class Main {


		public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		while(true){
			int num = 0;
			String moji = scan.next();
			int moji_len = moji.length();
			//??§????????¨?°????????????\??????????????????
			for(int cnt_len = 0; cnt_len < moji_len; cnt_len++){
				char moji_one = moji.charAt(cnt_len);
				String moji_str = String.valueOf(moji_one);
				int moji_int = Integer.decode(moji_str);
				num += moji_int;
			}
			//0?????\???????????????????????¨?????????????????????
			if(num == 0)
				break;
			else
				System.out.println(num);
		}
		//????§????
		scan.close();
	}
}