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) {

			char[] cdata = sc.nextLine().toCharArray();
			if ( cdata.length==1 && cdata[0]=='0' ) break;

			int sum =0;

			int[] idata = new int[cdata.length];
			for (int i=0; i < cdata.length; i++) {
				idata[i] = Character.getNumericValue( cdata[i] );
				sum += idata[i];
			}

			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) {

			char[] cdata = sc.nextLine().toCharArray();
			if ( cdata.length==1 && cdata[0]=='0' ) break;

			int sum =0;

			int[] idata = new int[cdata.length];
			for (int i=0; i < cdata.length; i++) {
				idata[i] = Character.getNumericValue( cdata[i] );
				sum += idata[i];
			}

			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) {

			char[] cdata = sc.nextLine().toCharArray();
			if ( cdata.length==1 && cdata[0]=='0' ) break;

			int sum =0;

			int[] idata = new int[cdata.length];
			for (int i=0; i < cdata.length; i++) {
				idata[i] = Character.getNumericValue( cdata[i] );
				sum += idata[i];
			}

			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) {

			char[] cdata = sc.nextLine().toCharArray();
			if ( cdata.length==1 && cdata[0]=='0' ) break;

			int sum =0;

			int[] idata = new int[cdata.length];
			for (int i=0; i < cdata.length; i++) {
				idata[i] = Character.getNumericValue( cdata[i] );
				sum += idata[i];
			}

			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) {

			char[] cdata = sc.nextLine().toCharArray();
			if ( cdata.length==1 && cdata[0]=='0' ) break;

			int sum =0;

			int[] idata = new int[cdata.length];
			for (int i=0; i < cdata.length; i++) {
				idata[i] = Character.getNumericValue( cdata[i] );
				sum += idata[i];
			}

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

		} true {

			char[] cdata = sc.nextLine().toCharArray();
			if ( cdata.length==1 && cdata[0]=='0' ) break;

			int sum =0;

			int[] idata = new int[cdata.length];
			for (int i=0; i < cdata.length; i++) {
				idata[i] = Character.getNumericValue( cdata[i] );
				sum += idata[i];
			}

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

		} char[] cdata = sc.nextLine().toCharArray(); cdata sc.nextLine().toCharArray() sc.nextLine().toCharArray sc.nextLine() sc.nextLine sc if ( cdata.length==1 && cdata[0]=='0' ) break; cdata.length==1 && cdata[0]=='0' cdata.length==1 cdata.length cdata cdata.length 1 cdata[0]=='0' cdata[0] cdata 0 '0' break; int sum =0; sum 0 int[] idata = new int[cdata.length]; idata new int[cdata.length] cdata.length cdata cdata.length for (int i=0; i < cdata.length; i++) {
				idata[i] = Character.getNumericValue( cdata[i] );
				sum += idata[i];
			} int i=0; int i=0; i 0 i < cdata.length i cdata.length cdata cdata.length i++ i++ i {
				idata[i] = Character.getNumericValue( cdata[i] );
				sum += idata[i];
			} {
				idata[i] = Character.getNumericValue( cdata[i] );
				sum += idata[i];
			} idata[i] = Character.getNumericValue( cdata[i] ) idata[i] idata i Character.getNumericValue( cdata[i] ) Character.getNumericValue Character cdata[i] cdata i sum += idata[i] sum idata[i] idata i 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) {

			char[] cdata = sc.nextLine().toCharArray();
			if ( cdata.length==1 && cdata[0]=='0' ) break;

			int sum =0;

			int[] idata = new int[cdata.length];
			for (int i=0; i < cdata.length; i++) {
				idata[i] = Character.getNumericValue( cdata[i] );
				sum += idata[i];
			}

			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) {

			char[] cdata = sc.nextLine().toCharArray();
			if ( cdata.length==1 && cdata[0]=='0' ) break;

			int sum =0;

			int[] idata = new int[cdata.length];
			for (int i=0; i < cdata.length; i++) {
				idata[i] = Character.getNumericValue( cdata[i] );
				sum += idata[i];
			}

			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) {

			char[] cdata = sc.nextLine().toCharArray();
			if ( cdata.length==1 && cdata[0]=='0' ) break;

			int sum =0;

			int[] idata = new int[cdata.length];
			for (int i=0; i < cdata.length; i++) {
				idata[i] = Character.getNumericValue( cdata[i] );
				sum += idata[i];
			}

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

		}

		System.out.print(sb);

	}

}