import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    ArrayList<Integer> result = new ArrayList<Integer>();
	    while (true) {
		    String line = br.readLine();

		    if ("0".equals(line)) break;

		    int sum = 0;
		    for (int i = 0; i < line.length(); i++) {
		    	char c = line.charAt(i);
		    	String s = String.valueOf(c);
		    	sum += Integer.parseInt(s);
		    }
		    result.add(sum);
	    }

	    // Display Anaser
	    StringBuilder sb = new StringBuilder();
	    for (int i = 0; i < result.size(); i++) {
	    	sb.append(result.get(i));
    		sb.append("\n");
	    }
	    System.out.print(sb.toString());
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    ArrayList<Integer> result = new ArrayList<Integer>();
	    while (true) {
		    String line = br.readLine();

		    if ("0".equals(line)) break;

		    int sum = 0;
		    for (int i = 0; i < line.length(); i++) {
		    	char c = line.charAt(i);
		    	String s = String.valueOf(c);
		    	sum += Integer.parseInt(s);
		    }
		    result.add(sum);
	    }

	    // Display Anaser
	    StringBuilder sb = new StringBuilder();
	    for (int i = 0; i < result.size(); i++) {
	    	sb.append(result.get(i));
    		sb.append("\n");
	    }
	    System.out.print(sb.toString());
	}
} Main public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    ArrayList<Integer> result = new ArrayList<Integer>();
	    while (true) {
		    String line = br.readLine();

		    if ("0".equals(line)) break;

		    int sum = 0;
		    for (int i = 0; i < line.length(); i++) {
		    	char c = line.charAt(i);
		    	String s = String.valueOf(c);
		    	sum += Integer.parseInt(s);
		    }
		    result.add(sum);
	    }

	    // Display Anaser
	    StringBuilder sb = new StringBuilder();
	    for (int i = 0; i < result.size(); i++) {
	    	sb.append(result.get(i));
    		sb.append("\n");
	    }
	    System.out.print(sb.toString());
	} main {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    ArrayList<Integer> result = new ArrayList<Integer>();
	    while (true) {
		    String line = br.readLine();

		    if ("0".equals(line)) break;

		    int sum = 0;
		    for (int i = 0; i < line.length(); i++) {
		    	char c = line.charAt(i);
		    	String s = String.valueOf(c);
		    	sum += Integer.parseInt(s);
		    }
		    result.add(sum);
	    }

	    // Display Anaser
	    StringBuilder sb = new StringBuilder();
	    for (int i = 0; i < result.size(); i++) {
	    	sb.append(result.get(i));
    		sb.append("\n");
	    }
	    System.out.print(sb.toString());
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) ArrayList<Integer> result = new ArrayList<Integer>(); result new ArrayList<Integer>() while (true) {
		    String line = br.readLine();

		    if ("0".equals(line)) break;

		    int sum = 0;
		    for (int i = 0; i < line.length(); i++) {
		    	char c = line.charAt(i);
		    	String s = String.valueOf(c);
		    	sum += Integer.parseInt(s);
		    }
		    result.add(sum);
	    } true {
		    String line = br.readLine();

		    if ("0".equals(line)) break;

		    int sum = 0;
		    for (int i = 0; i < line.length(); i++) {
		    	char c = line.charAt(i);
		    	String s = String.valueOf(c);
		    	sum += Integer.parseInt(s);
		    }
		    result.add(sum);
	    } String line = br.readLine(); line br.readLine() br.readLine br if ("0".equals(line)) break; "0".equals(line) "0".equals "0" line break; int sum = 0; sum 0 for (int i = 0; i < line.length(); i++) {
		    	char c = line.charAt(i);
		    	String s = String.valueOf(c);
		    	sum += Integer.parseInt(s);
		    } int i = 0; int i = 0; i 0 i < line.length() i line.length() line.length line i++ i++ i {
		    	char c = line.charAt(i);
		    	String s = String.valueOf(c);
		    	sum += Integer.parseInt(s);
		    } {
		    	char c = line.charAt(i);
		    	String s = String.valueOf(c);
		    	sum += Integer.parseInt(s);
		    } char c = line.charAt(i); c line.charAt(i) line.charAt line i String s = String.valueOf(c); s String.valueOf(c) String.valueOf String c sum += Integer.parseInt(s) sum Integer.parseInt(s) Integer.parseInt Integer s result.add(sum) result.add result sum StringBuilder sb = new StringBuilder(); sb new StringBuilder() for (int i = 0; i < result.size(); i++) {
	    	sb.append(result.get(i));
    		sb.append("\n");
	    } int i = 0; int i = 0; i 0 i < result.size() i result.size() result.size result i++ i++ i {
	    	sb.append(result.get(i));
    		sb.append("\n");
	    } {
	    	sb.append(result.get(i));
    		sb.append("\n");
	    } sb.append(result.get(i)) sb.append sb result.get(i) result.get result i sb.append("\n") sb.append sb "\n" System.out.print(sb.toString()) System.out.print System.out System System.out sb.toString() sb.toString sb String[] args args public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    ArrayList<Integer> result = new ArrayList<Integer>();
	    while (true) {
		    String line = br.readLine();

		    if ("0".equals(line)) break;

		    int sum = 0;
		    for (int i = 0; i < line.length(); i++) {
		    	char c = line.charAt(i);
		    	String s = String.valueOf(c);
		    	sum += Integer.parseInt(s);
		    }
		    result.add(sum);
	    }

	    // Display Anaser
	    StringBuilder sb = new StringBuilder();
	    for (int i = 0; i < result.size(); i++) {
	    	sb.append(result.get(i));
    		sb.append("\n");
	    }
	    System.out.print(sb.toString());
	}
} public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    ArrayList<Integer> result = new ArrayList<Integer>();
	    while (true) {
		    String line = br.readLine();

		    if ("0".equals(line)) break;

		    int sum = 0;
		    for (int i = 0; i < line.length(); i++) {
		    	char c = line.charAt(i);
		    	String s = String.valueOf(c);
		    	sum += Integer.parseInt(s);
		    }
		    result.add(sum);
	    }

	    // Display Anaser
	    StringBuilder sb = new StringBuilder();
	    for (int i = 0; i < result.size(); i++) {
	    	sb.append(result.get(i));
    		sb.append("\n");
	    }
	    System.out.print(sb.toString());
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    ArrayList<Integer> result = new ArrayList<Integer>();
	    while (true) {
		    String line = br.readLine();

		    if ("0".equals(line)) break;

		    int sum = 0;
		    for (int i = 0; i < line.length(); i++) {
		    	char c = line.charAt(i);
		    	String s = String.valueOf(c);
		    	sum += Integer.parseInt(s);
		    }
		    result.add(sum);
	    }

	    // Display Anaser
	    StringBuilder sb = new StringBuilder();
	    for (int i = 0; i < result.size(); i++) {
	    	sb.append(result.get(i));
    		sb.append("\n");
	    }
	    System.out.print(sb.toString());
	}
}