import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		String x = scan.next();
		if(x.equals("0"))
			break;
		String b[] = x.split("");
		int i,m,ans;
		ans = 0;
		for(i = 0; i < x.length(); i++){
			for(m = 0; m <= 9; m++){
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			}
		}
		System.out.println(ans);
		}
		
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		String x = scan.next();
		if(x.equals("0"))
			break;
		String b[] = x.split("");
		int i,m,ans;
		ans = 0;
		for(i = 0; i < x.length(); i++){
			for(m = 0; m <= 9; m++){
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			}
		}
		System.out.println(ans);
		}
		
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		String x = scan.next();
		if(x.equals("0"))
			break;
		String b[] = x.split("");
		int i,m,ans;
		ans = 0;
		for(i = 0; i < x.length(); i++){
			for(m = 0; m <= 9; m++){
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			}
		}
		System.out.println(ans);
		}
		
	} main {
		Scanner scan = new Scanner(System.in);
		for(;;){
		String x = scan.next();
		if(x.equals("0"))
			break;
		String b[] = x.split("");
		int i,m,ans;
		ans = 0;
		for(i = 0; i < x.length(); i++){
			for(m = 0; m <= 9; m++){
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			}
		}
		System.out.println(ans);
		}
		
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) for(;;){
		String x = scan.next();
		if(x.equals("0"))
			break;
		String b[] = x.split("");
		int i,m,ans;
		ans = 0;
		for(i = 0; i < x.length(); i++){
			for(m = 0; m <= 9; m++){
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			}
		}
		System.out.println(ans);
		} ; {
		String x = scan.next();
		if(x.equals("0"))
			break;
		String b[] = x.split("");
		int i,m,ans;
		ans = 0;
		for(i = 0; i < x.length(); i++){
			for(m = 0; m <= 9; m++){
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			}
		}
		System.out.println(ans);
		} {
		String x = scan.next();
		if(x.equals("0"))
			break;
		String b[] = x.split("");
		int i,m,ans;
		ans = 0;
		for(i = 0; i < x.length(); i++){
			for(m = 0; m <= 9; m++){
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			}
		}
		System.out.println(ans);
		} String x = scan.next(); x scan.next() scan.next scan if(x.equals("0"))
			break; x.equals("0") x.equals x "0" break; String b[] = x.split(""); b x.split("") x.split x "" int i i m m ans; ans ans = 0 ans 0 for(i = 0; i < x.length(); i++){
			for(m = 0; m <= 9; m++){
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			}
		} i = 0; i = 0 i 0 i < x.length() i x.length() x.length x i++ i++ i {
			for(m = 0; m <= 9; m++){
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			}
		} {
			for(m = 0; m <= 9; m++){
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			}
		} for(m = 0; m <= 9; m++){
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			} m = 0; m = 0 m 0 m <= 9 m 9 m++ m++ m {
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			} {
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			} Integer num = new Integer(m); num new Integer(m) String str2 = num.toString(); str2 num.toString() num.toString num if(b[i].equals(str2))
					ans += m; b[i].equals(str2) b[i].equals b[i] b i str2 ans += m ans m System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		String x = scan.next();
		if(x.equals("0"))
			break;
		String b[] = x.split("");
		int i,m,ans;
		ans = 0;
		for(i = 0; i < x.length(); i++){
			for(m = 0; m <= 9; m++){
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			}
		}
		System.out.println(ans);
		}
		
	}
} public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		String x = scan.next();
		if(x.equals("0"))
			break;
		String b[] = x.split("");
		int i,m,ans;
		ans = 0;
		for(i = 0; i < x.length(); i++){
			for(m = 0; m <= 9; m++){
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			}
		}
		System.out.println(ans);
		}
		
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		String x = scan.next();
		if(x.equals("0"))
			break;
		String b[] = x.split("");
		int i,m,ans;
		ans = 0;
		for(i = 0; i < x.length(); i++){
			for(m = 0; m <= 9; m++){
				Integer num = new Integer(m);
				String str2 = num.toString();
				if(b[i].equals(str2))
					ans += m;
			}
		}
		System.out.println(ans);
		}
		
	}
}