import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String s = sc.next();
			if(s.equals("0")) break;
			int ret = 0;
			for(int i = 0; i < s.length(); i++) ret += s.charAt(i) - 48;
			System.out.println(ret);
		}
	}
} import java.util.*; util.* java class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String s = sc.next();
			if(s.equals("0")) break;
			int ret = 0;
			for(int i = 0; i < s.length(); i++) ret += s.charAt(i) - 48;
			System.out.println(ret);
		}
	}
} Main public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String s = sc.next();
			if(s.equals("0")) break;
			int ret = 0;
			for(int i = 0; i < s.length(); i++) ret += s.charAt(i) - 48;
			System.out.println(ret);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String s = sc.next();
			if(s.equals("0")) break;
			int ret = 0;
			for(int i = 0; i < s.length(); i++) ret += s.charAt(i) - 48;
			System.out.println(ret);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true) {
			String s = sc.next();
			if(s.equals("0")) break;
			int ret = 0;
			for(int i = 0; i < s.length(); i++) ret += s.charAt(i) - 48;
			System.out.println(ret);
		} true {
			String s = sc.next();
			if(s.equals("0")) break;
			int ret = 0;
			for(int i = 0; i < s.length(); i++) ret += s.charAt(i) - 48;
			System.out.println(ret);
		} String s = sc.next(); s sc.next() sc.next sc if(s.equals("0")) break; s.equals("0") s.equals s "0" break; int ret = 0; ret 0 for(int i = 0; i < s.length(); i++) ret += s.charAt(i) - 48; int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i ret += s.charAt(i) - 48; ret += s.charAt(i) - 48 ret s.charAt(i) - 48 s.charAt(i) s.charAt s i 48 System.out.println(ret) System.out.println System.out System System.out ret String[] args args
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String s = sc.next();
			if(s.equals("0")) break;
			int ret = 0;
			for(int i = 0; i < s.length(); i++) ret += s.charAt(i) - 48;
			System.out.println(ret);
		}
	}
}