import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
//
//		while (true) {
//			long x = scan.nextLong();
//			if (x == 0l) {break;}
//			long sum = 0l;
//			while (x != 0l) {
//				sum += x % 10l;
//				x /= 10l;
//			}
//			sb.append(sum + "\n");
//		}
//		System.out.print(sb);

		while (true) {
			String x = scan.next();

			if ( x.equals("0") ) {break;}

			char[] xx = x.toCharArray();
			int l = xx.length;
			int sum = 0;
			for (int i = 0; i < l; i++) {
				sum += Character.getNumericValue(xx[i]);
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
//
//		while (true) {
//			long x = scan.nextLong();
//			if (x == 0l) {break;}
//			long sum = 0l;
//			while (x != 0l) {
//				sum += x % 10l;
//				x /= 10l;
//			}
//			sb.append(sum + "\n");
//		}
//		System.out.print(sb);

		while (true) {
			String x = scan.next();

			if ( x.equals("0") ) {break;}

			char[] xx = x.toCharArray();
			int l = xx.length;
			int sum = 0;
			for (int i = 0; i < l; i++) {
				sum += Character.getNumericValue(xx[i]);
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb);
	}

} Main public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
//
//		while (true) {
//			long x = scan.nextLong();
//			if (x == 0l) {break;}
//			long sum = 0l;
//			while (x != 0l) {
//				sum += x % 10l;
//				x /= 10l;
//			}
//			sb.append(sum + "\n");
//		}
//		System.out.print(sb);

		while (true) {
			String x = scan.next();

			if ( x.equals("0") ) {break;}

			char[] xx = x.toCharArray();
			int l = xx.length;
			int sum = 0;
			for (int i = 0; i < l; i++) {
				sum += Character.getNumericValue(xx[i]);
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb);
	} main {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
//
//		while (true) {
//			long x = scan.nextLong();
//			if (x == 0l) {break;}
//			long sum = 0l;
//			while (x != 0l) {
//				sum += x % 10l;
//				x /= 10l;
//			}
//			sb.append(sum + "\n");
//		}
//		System.out.print(sb);

		while (true) {
			String x = scan.next();

			if ( x.equals("0") ) {break;}

			char[] xx = x.toCharArray();
			int l = xx.length;
			int sum = 0;
			for (int i = 0; i < l; i++) {
				sum += Character.getNumericValue(xx[i]);
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while (true) {
			String x = scan.next();

			if ( x.equals("0") ) {break;}

			char[] xx = x.toCharArray();
			int l = xx.length;
			int sum = 0;
			for (int i = 0; i < l; i++) {
				sum += Character.getNumericValue(xx[i]);
			}
			sb.append(sum + "\n");
		} true {
			String x = scan.next();

			if ( x.equals("0") ) {break;}

			char[] xx = x.toCharArray();
			int l = xx.length;
			int sum = 0;
			for (int i = 0; i < l; i++) {
				sum += Character.getNumericValue(xx[i]);
			}
			sb.append(sum + "\n");
		} String x = scan.next(); x scan.next() scan.next scan if ( x.equals("0") ) {break;} x.equals("0") x.equals x "0" {break;} break; char[] xx = x.toCharArray(); xx x.toCharArray() x.toCharArray x int l = xx.length; l xx.length xx xx.length int sum = 0; sum 0 for (int i = 0; i < l; i++) {
				sum += Character.getNumericValue(xx[i]);
			} int i = 0; int i = 0; i 0 i < l i l i++ i++ i {
				sum += Character.getNumericValue(xx[i]);
			} {
				sum += Character.getNumericValue(xx[i]);
			} sum += Character.getNumericValue(xx[i]) sum Character.getNumericValue(xx[i]) Character.getNumericValue Character xx[i] xx 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 ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
//
//		while (true) {
//			long x = scan.nextLong();
//			if (x == 0l) {break;}
//			long sum = 0l;
//			while (x != 0l) {
//				sum += x % 10l;
//				x /= 10l;
//			}
//			sb.append(sum + "\n");
//		}
//		System.out.print(sb);

		while (true) {
			String x = scan.next();

			if ( x.equals("0") ) {break;}

			char[] xx = x.toCharArray();
			int l = xx.length;
			int sum = 0;
			for (int i = 0; i < l; i++) {
				sum += Character.getNumericValue(xx[i]);
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
//
//		while (true) {
//			long x = scan.nextLong();
//			if (x == 0l) {break;}
//			long sum = 0l;
//			while (x != 0l) {
//				sum += x % 10l;
//				x /= 10l;
//			}
//			sb.append(sum + "\n");
//		}
//		System.out.print(sb);

		while (true) {
			String x = scan.next();

			if ( x.equals("0") ) {break;}

			char[] xx = x.toCharArray();
			int l = xx.length;
			int sum = 0;
			for (int i = 0; i < l; i++) {
				sum += Character.getNumericValue(xx[i]);
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
//
//		while (true) {
//			long x = scan.nextLong();
//			if (x == 0l) {break;}
//			long sum = 0l;
//			while (x != 0l) {
//				sum += x % 10l;
//				x /= 10l;
//			}
//			sb.append(sum + "\n");
//		}
//		System.out.print(sb);

		while (true) {
			String x = scan.next();

			if ( x.equals("0") ) {break;}

			char[] xx = x.toCharArray();
			int l = xx.length;
			int sum = 0;
			for (int i = 0; i < l; i++) {
				sum += Character.getNumericValue(xx[i]);
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb);
	}

}