public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			String data = sc.nextLine();
			if ( data.equals("0") ) break;

			int sum = 0;
			for (int i=0; i < data.length(); i++) {
				sum += Integer.parseInt( data.substring(i, i+1) );
			}

			sb.append(sum + "\n");

		}

		System.out.print(sb);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			String data = sc.nextLine();
			if ( data.equals("0") ) break;

			int sum = 0;
			for (int i=0; i < data.length(); i++) {
				sum += Integer.parseInt( data.substring(i, i+1) );
			}

			sb.append(sum + "\n");

		}

		System.out.print(sb);
	}

} Main public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			String data = sc.nextLine();
			if ( data.equals("0") ) break;

			int sum = 0;
			for (int i=0; i < data.length(); i++) {
				sum += Integer.parseInt( data.substring(i, i+1) );
			}

			sb.append(sum + "\n");

		}

		System.out.print(sb);
	} main {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			String data = sc.nextLine();
			if ( data.equals("0") ) break;

			int sum = 0;
			for (int i=0; i < data.length(); i++) {
				sum += Integer.parseInt( data.substring(i, i+1) );
			}

			sb.append(sum + "\n");

		}

		System.out.print(sb);
	} java.util.Scanner sc = new java.util.Scanner(System.in); sc new java.util.Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while (true) {

			String data = sc.nextLine();
			if ( data.equals("0") ) break;

			int sum = 0;
			for (int i=0; i < data.length(); i++) {
				sum += Integer.parseInt( data.substring(i, i+1) );
			}

			sb.append(sum + "\n");

		} true {

			String data = sc.nextLine();
			if ( data.equals("0") ) break;

			int sum = 0;
			for (int i=0; i < data.length(); i++) {
				sum += Integer.parseInt( data.substring(i, i+1) );
			}

			sb.append(sum + "\n");

		} String data = sc.nextLine(); data sc.nextLine() sc.nextLine sc if ( data.equals("0") ) break; data.equals("0") data.equals data "0" break; int sum = 0; sum 0 for (int i=0; i < data.length(); i++) {
				sum += Integer.parseInt( data.substring(i, i+1) );
			} int i=0; int i=0; i 0 i < data.length() i data.length() data.length data i++ i++ i {
				sum += Integer.parseInt( data.substring(i, i+1) );
			} {
				sum += Integer.parseInt( data.substring(i, i+1) );
			} sum += Integer.parseInt( data.substring(i, i+1) ) sum Integer.parseInt( data.substring(i, i+1) ) Integer.parseInt Integer data.substring(i, i+1) data.substring data i i+1 i 1 sb.append(sum + "\n") sb.append sb sum + "\n" sum "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			String data = sc.nextLine();
			if ( data.equals("0") ) break;

			int sum = 0;
			for (int i=0; i < data.length(); i++) {
				sum += Integer.parseInt( data.substring(i, i+1) );
			}

			sb.append(sum + "\n");

		}

		System.out.print(sb);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			String data = sc.nextLine();
			if ( data.equals("0") ) break;

			int sum = 0;
			for (int i=0; i < data.length(); i++) {
				sum += Integer.parseInt( data.substring(i, i+1) );
			}

			sb.append(sum + "\n");

		}

		System.out.print(sb);
	}

} Main
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			String data = sc.nextLine();
			if ( data.equals("0") ) break;

			int sum = 0;
			for (int i=0; i < data.length(); i++) {
				sum += Integer.parseInt( data.substring(i, i+1) );
			}

			sb.append(sum + "\n");

		}

		System.out.print(sb);
	}

}