import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	
	static int k(char a) {
		if(a == '0') {
			return 0;
		}
		else if(a == '1') {
			return 1;
		}
		else if(a == '2') {
			return 2;
		}
		else if(a == '3') {
			return 3;
		}
		else if(a == '4') {
			return 4;
		}
		else if(a == '5') {
			return 5;
		}
		else if(a == '6') {
			return 6;
		}
		else if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		}
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		List <String> a = new ArrayList<String>();
		String tmp;
		do {
			tmp = stdIn.next();
			a.add(tmp);
		}while(!tmp.equals("0"));
		
		for(int i = 0; i < a.size()-1; i++) {
			tmp = a.get(i);
			int tmpk = 0;
			for(int j = 0; j < tmp.length(); j++) {
				tmpk += k(tmp.charAt(j));
			}
			System.out.println(tmpk);
		}
		
		

	}

} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	
	static int k(char a) {
		if(a == '0') {
			return 0;
		}
		else if(a == '1') {
			return 1;
		}
		else if(a == '2') {
			return 2;
		}
		else if(a == '3') {
			return 3;
		}
		else if(a == '4') {
			return 4;
		}
		else if(a == '5') {
			return 5;
		}
		else if(a == '6') {
			return 6;
		}
		else if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		}
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		List <String> a = new ArrayList<String>();
		String tmp;
		do {
			tmp = stdIn.next();
			a.add(tmp);
		}while(!tmp.equals("0"));
		
		for(int i = 0; i < a.size()-1; i++) {
			tmp = a.get(i);
			int tmpk = 0;
			for(int j = 0; j < tmp.length(); j++) {
				tmpk += k(tmp.charAt(j));
			}
			System.out.println(tmpk);
		}
		
		

	}

} Main static int k(char a) {
		if(a == '0') {
			return 0;
		}
		else if(a == '1') {
			return 1;
		}
		else if(a == '2') {
			return 2;
		}
		else if(a == '3') {
			return 3;
		}
		else if(a == '4') {
			return 4;
		}
		else if(a == '5') {
			return 5;
		}
		else if(a == '6') {
			return 6;
		}
		else if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		}
	} k {
		if(a == '0') {
			return 0;
		}
		else if(a == '1') {
			return 1;
		}
		else if(a == '2') {
			return 2;
		}
		else if(a == '3') {
			return 3;
		}
		else if(a == '4') {
			return 4;
		}
		else if(a == '5') {
			return 5;
		}
		else if(a == '6') {
			return 6;
		}
		else if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		}
	} if(a == '0') {
			return 0;
		}
		else if(a == '1') {
			return 1;
		}
		else if(a == '2') {
			return 2;
		}
		else if(a == '3') {
			return 3;
		}
		else if(a == '4') {
			return 4;
		}
		else if(a == '5') {
			return 5;
		}
		else if(a == '6') {
			return 6;
		}
		else if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		} a == '0' a '0' {
			return 0;
		} return 0; 0 if(a == '1') {
			return 1;
		}
		else if(a == '2') {
			return 2;
		}
		else if(a == '3') {
			return 3;
		}
		else if(a == '4') {
			return 4;
		}
		else if(a == '5') {
			return 5;
		}
		else if(a == '6') {
			return 6;
		}
		else if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		} a == '1' a '1' {
			return 1;
		} return 1; 1 if(a == '2') {
			return 2;
		}
		else if(a == '3') {
			return 3;
		}
		else if(a == '4') {
			return 4;
		}
		else if(a == '5') {
			return 5;
		}
		else if(a == '6') {
			return 6;
		}
		else if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		} a == '2' a '2' {
			return 2;
		} return 2; 2 if(a == '3') {
			return 3;
		}
		else if(a == '4') {
			return 4;
		}
		else if(a == '5') {
			return 5;
		}
		else if(a == '6') {
			return 6;
		}
		else if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		} a == '3' a '3' {
			return 3;
		} return 3; 3 if(a == '4') {
			return 4;
		}
		else if(a == '5') {
			return 5;
		}
		else if(a == '6') {
			return 6;
		}
		else if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		} a == '4' a '4' {
			return 4;
		} return 4; 4 if(a == '5') {
			return 5;
		}
		else if(a == '6') {
			return 6;
		}
		else if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		} a == '5' a '5' {
			return 5;
		} return 5; 5 if(a == '6') {
			return 6;
		}
		else if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		} a == '6' a '6' {
			return 6;
		} return 6; 6 if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		} a == '7' a '7' {
			return 7;
		} return 7; 7 if(a == '8') {
			return 8;
		}
		else {
			return 9;
		} a == '8' a '8' {
			return 8;
		} return 8; 8 {
			return 9;
		} return 9; 9 char a a public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		List <String> a = new ArrayList<String>();
		String tmp;
		do {
			tmp = stdIn.next();
			a.add(tmp);
		}while(!tmp.equals("0"));
		
		for(int i = 0; i < a.size()-1; i++) {
			tmp = a.get(i);
			int tmpk = 0;
			for(int j = 0; j < tmp.length(); j++) {
				tmpk += k(tmp.charAt(j));
			}
			System.out.println(tmpk);
		}
		
		

	} main {
		Scanner stdIn = new Scanner(System.in);
		List <String> a = new ArrayList<String>();
		String tmp;
		do {
			tmp = stdIn.next();
			a.add(tmp);
		}while(!tmp.equals("0"));
		
		for(int i = 0; i < a.size()-1; i++) {
			tmp = a.get(i);
			int tmpk = 0;
			for(int j = 0; j < tmp.length(); j++) {
				tmpk += k(tmp.charAt(j));
			}
			System.out.println(tmpk);
		}
		
		

	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) List <String> a = new ArrayList<String>(); a new ArrayList<String>() String tmp; tmp do {
			tmp = stdIn.next();
			a.add(tmp);
		}while(!tmp.equals("0")); !tmp.equals("0") tmp.equals("0") tmp.equals tmp "0" {
			tmp = stdIn.next();
			a.add(tmp);
		} tmp = stdIn.next() tmp stdIn.next() stdIn.next stdIn a.add(tmp) a.add a tmp for(int i = 0; i < a.size()-1; i++) {
			tmp = a.get(i);
			int tmpk = 0;
			for(int j = 0; j < tmp.length(); j++) {
				tmpk += k(tmp.charAt(j));
			}
			System.out.println(tmpk);
		} int i = 0; int i = 0; i 0 i < a.size()-1 i a.size()-1 a.size() a.size a 1 i++ i++ i {
			tmp = a.get(i);
			int tmpk = 0;
			for(int j = 0; j < tmp.length(); j++) {
				tmpk += k(tmp.charAt(j));
			}
			System.out.println(tmpk);
		} {
			tmp = a.get(i);
			int tmpk = 0;
			for(int j = 0; j < tmp.length(); j++) {
				tmpk += k(tmp.charAt(j));
			}
			System.out.println(tmpk);
		} tmp = a.get(i) tmp a.get(i) a.get a i int tmpk = 0; tmpk 0 for(int j = 0; j < tmp.length(); j++) {
				tmpk += k(tmp.charAt(j));
			} int j = 0; int j = 0; j 0 j < tmp.length() j tmp.length() tmp.length tmp j++ j++ j {
				tmpk += k(tmp.charAt(j));
			} {
				tmpk += k(tmp.charAt(j));
			} tmpk += k(tmp.charAt(j)) tmpk k(tmp.charAt(j)) k tmp.charAt(j) tmp.charAt tmp j System.out.println(tmpk) System.out.println System.out System System.out tmpk String[] args args public class Main {
	
	static int k(char a) {
		if(a == '0') {
			return 0;
		}
		else if(a == '1') {
			return 1;
		}
		else if(a == '2') {
			return 2;
		}
		else if(a == '3') {
			return 3;
		}
		else if(a == '4') {
			return 4;
		}
		else if(a == '5') {
			return 5;
		}
		else if(a == '6') {
			return 6;
		}
		else if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		}
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		List <String> a = new ArrayList<String>();
		String tmp;
		do {
			tmp = stdIn.next();
			a.add(tmp);
		}while(!tmp.equals("0"));
		
		for(int i = 0; i < a.size()-1; i++) {
			tmp = a.get(i);
			int tmpk = 0;
			for(int j = 0; j < tmp.length(); j++) {
				tmpk += k(tmp.charAt(j));
			}
			System.out.println(tmpk);
		}
		
		

	}

} public class Main {
	
	static int k(char a) {
		if(a == '0') {
			return 0;
		}
		else if(a == '1') {
			return 1;
		}
		else if(a == '2') {
			return 2;
		}
		else if(a == '3') {
			return 3;
		}
		else if(a == '4') {
			return 4;
		}
		else if(a == '5') {
			return 5;
		}
		else if(a == '6') {
			return 6;
		}
		else if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		}
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		List <String> a = new ArrayList<String>();
		String tmp;
		do {
			tmp = stdIn.next();
			a.add(tmp);
		}while(!tmp.equals("0"));
		
		for(int i = 0; i < a.size()-1; i++) {
			tmp = a.get(i);
			int tmpk = 0;
			for(int j = 0; j < tmp.length(); j++) {
				tmpk += k(tmp.charAt(j));
			}
			System.out.println(tmpk);
		}
		
		

	}

} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	
	static int k(char a) {
		if(a == '0') {
			return 0;
		}
		else if(a == '1') {
			return 1;
		}
		else if(a == '2') {
			return 2;
		}
		else if(a == '3') {
			return 3;
		}
		else if(a == '4') {
			return 4;
		}
		else if(a == '5') {
			return 5;
		}
		else if(a == '6') {
			return 6;
		}
		else if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		}
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		List <String> a = new ArrayList<String>();
		String tmp;
		do {
			tmp = stdIn.next();
			a.add(tmp);
		}while(!tmp.equals("0"));
		
		for(int i = 0; i < a.size()-1; i++) {
			tmp = a.get(i);
			int tmpk = 0;
			for(int j = 0; j < tmp.length(); j++) {
				tmpk += k(tmp.charAt(j));
			}
			System.out.println(tmpk);
		}
		
		

	}

}