import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int sum = 0;
	while (scan.hasNext()) {
	    String number = scan.nextLine();
	    if (number.equals("0")) {
		break;
	    }
	    System.out.println(sum(number));
	}
    }
    public static int sum (String number) {
	int sum = 0;
	for (int i = 0; i < number.length(); i++) {
	    sum += Integer.valueOf(number.substring(i, i+1));
	}
	return sum;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int sum = 0;
	while (scan.hasNext()) {
	    String number = scan.nextLine();
	    if (number.equals("0")) {
		break;
	    }
	    System.out.println(sum(number));
	}
    }
    public static int sum (String number) {
	int sum = 0;
	for (int i = 0; i < number.length(); i++) {
	    sum += Integer.valueOf(number.substring(i, i+1));
	}
	return sum;
    }
} Main public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int sum = 0;
	while (scan.hasNext()) {
	    String number = scan.nextLine();
	    if (number.equals("0")) {
		break;
	    }
	    System.out.println(sum(number));
	}
    } main {
	Scanner scan = new Scanner(System.in);
	int sum = 0;
	while (scan.hasNext()) {
	    String number = scan.nextLine();
	    if (number.equals("0")) {
		break;
	    }
	    System.out.println(sum(number));
	}
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int sum = 0; sum 0 while (scan.hasNext()) {
	    String number = scan.nextLine();
	    if (number.equals("0")) {
		break;
	    }
	    System.out.println(sum(number));
	} scan.hasNext() scan.hasNext scan {
	    String number = scan.nextLine();
	    if (number.equals("0")) {
		break;
	    }
	    System.out.println(sum(number));
	} String number = scan.nextLine(); number scan.nextLine() scan.nextLine scan if (number.equals("0")) {
		break;
	    } number.equals("0") number.equals number "0" {
		break;
	    } break; System.out.println(sum(number)) System.out.println System.out System System.out sum(number) sum number String[] args args public static int sum (String number) {
	int sum = 0;
	for (int i = 0; i < number.length(); i++) {
	    sum += Integer.valueOf(number.substring(i, i+1));
	}
	return sum;
    } sum {
	int sum = 0;
	for (int i = 0; i < number.length(); i++) {
	    sum += Integer.valueOf(number.substring(i, i+1));
	}
	return sum;
    } int sum = 0; sum 0 for (int i = 0; i < number.length(); i++) {
	    sum += Integer.valueOf(number.substring(i, i+1));
	} int i = 0; int i = 0; i 0 i < number.length() i number.length() number.length number i++ i++ i {
	    sum += Integer.valueOf(number.substring(i, i+1));
	} {
	    sum += Integer.valueOf(number.substring(i, i+1));
	} sum += Integer.valueOf(number.substring(i, i+1)) sum Integer.valueOf(number.substring(i, i+1)) Integer.valueOf Integer number.substring(i, i+1) number.substring number i i+1 i 1 return sum; sum String number number public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int sum = 0;
	while (scan.hasNext()) {
	    String number = scan.nextLine();
	    if (number.equals("0")) {
		break;
	    }
	    System.out.println(sum(number));
	}
    }
    public static int sum (String number) {
	int sum = 0;
	for (int i = 0; i < number.length(); i++) {
	    sum += Integer.valueOf(number.substring(i, i+1));
	}
	return sum;
    }
} public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int sum = 0;
	while (scan.hasNext()) {
	    String number = scan.nextLine();
	    if (number.equals("0")) {
		break;
	    }
	    System.out.println(sum(number));
	}
    }
    public static int sum (String number) {
	int sum = 0;
	for (int i = 0; i < number.length(); i++) {
	    sum += Integer.valueOf(number.substring(i, i+1));
	}
	return sum;
    }
} Main
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int sum = 0;
	while (scan.hasNext()) {
	    String number = scan.nextLine();
	    if (number.equals("0")) {
		break;
	    }
	    System.out.println(sum(number));
	}
    }
    public static int sum (String number) {
	int sum = 0;
	for (int i = 0; i < number.length(); i++) {
	    sum += Integer.valueOf(number.substring(i, i+1));
	}
	return sum;
    }
}