import java.awt.*;
import java.awt.geom.*;
import java.io.*;

import java.util.*;
class Main {

	static char[] xx = new char[] {'S','H','C','D'};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String in = sc.next();
			if(in.equals("0")) break;
			char[] x = in.toCharArray();
			int sum = 0;
			for(int i = 0; i < x.length; i++) {
				sum += x[i] - '0';
			}
			System.out.println(sum);
			
		}

	}
} import java.awt.*; awt.* java import java.awt.geom.*; geom.* java.awt import java.io.*; io.* java import java.util.*; util.* java class Main {

	static char[] xx = new char[] {'S','H','C','D'};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String in = sc.next();
			if(in.equals("0")) break;
			char[] x = in.toCharArray();
			int sum = 0;
			for(int i = 0; i < x.length; i++) {
				sum += x[i] - '0';
			}
			System.out.println(sum);
			
		}

	}
} Main static char[] xx = new char[] {'S','H','C','D'}; xx new char[] {'S','H','C','D'} public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String in = sc.next();
			if(in.equals("0")) break;
			char[] x = in.toCharArray();
			int sum = 0;
			for(int i = 0; i < x.length; i++) {
				sum += x[i] - '0';
			}
			System.out.println(sum);
			
		}

	} main {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String in = sc.next();
			if(in.equals("0")) break;
			char[] x = in.toCharArray();
			int sum = 0;
			for(int i = 0; i < x.length; i++) {
				sum += x[i] - '0';
			}
			System.out.println(sum);
			
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true) {
			String in = sc.next();
			if(in.equals("0")) break;
			char[] x = in.toCharArray();
			int sum = 0;
			for(int i = 0; i < x.length; i++) {
				sum += x[i] - '0';
			}
			System.out.println(sum);
			
		} true {
			String in = sc.next();
			if(in.equals("0")) break;
			char[] x = in.toCharArray();
			int sum = 0;
			for(int i = 0; i < x.length; i++) {
				sum += x[i] - '0';
			}
			System.out.println(sum);
			
		} String in = sc.next(); in sc.next() sc.next sc if(in.equals("0")) break; in.equals("0") in.equals in "0" break; char[] x = in.toCharArray(); x in.toCharArray() in.toCharArray in int sum = 0; sum 0 for(int i = 0; i < x.length; i++) {
				sum += x[i] - '0';
			} int i = 0; int i = 0; i 0 i < x.length i x.length x x.length i++ i++ i {
				sum += x[i] - '0';
			} {
				sum += x[i] - '0';
			} sum += x[i] - '0' sum x[i] - '0' x[i] x i '0' System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.awt.*;
import java.awt.geom.*;
import java.io.*;

import java.util.*;
class Main {

	static char[] xx = new char[] {'S','H','C','D'};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String in = sc.next();
			if(in.equals("0")) break;
			char[] x = in.toCharArray();
			int sum = 0;
			for(int i = 0; i < x.length; i++) {
				sum += x[i] - '0';
			}
			System.out.println(sum);
			
		}

	}
}