import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()).equals("0") == false) {
				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum = sum + x.charAt(i) - '0';
				}
				
				System.out.println(sum);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()).equals("0") == false) {
				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum = sum + x.charAt(i) - '0';
				}
				
				System.out.println(sum);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} Main public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()).equals("0") == false) {
				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum = sum + x.charAt(i) - '0';
				}
				
				System.out.println(sum);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()).equals("0") == false) {
				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum = sum + x.charAt(i) - '0';
				}
				
				System.out.println(sum);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String x = ""; x "" try {
			while ((x = in.readLine()).equals("0") == false) {
				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum = sum + x.charAt(i) - '0';
				}
				
				System.out.println(sum);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} NumberFormatException e {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} IOException e {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			while ((x = in.readLine()).equals("0") == false) {
				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum = sum + x.charAt(i) - '0';
				}
				
				System.out.println(sum);
			}
		} while ((x = in.readLine()).equals("0") == false) {
				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum = sum + x.charAt(i) - '0';
				}
				
				System.out.println(sum);
			} (x = in.readLine()).equals("0") == false (x = in.readLine()).equals("0") (x = in.readLine()).equals (x = in.readLine()) x in.readLine() in.readLine in "0" false {
				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum = sum + x.charAt(i) - '0';
				}
				
				System.out.println(sum);
			} int sum = 0; sum 0 for (int i = 0; i < x.length(); i++) {
					sum = sum + x.charAt(i) - '0';
				} int i = 0; int i = 0; i 0 i < x.length() i x.length() x.length x i++ i++ i {
					sum = sum + x.charAt(i) - '0';
				} {
					sum = sum + x.charAt(i) - '0';
				} sum = sum + x.charAt(i) - '0' sum sum + x.charAt(i) - '0' sum + x.charAt(i) sum x.charAt(i) x.charAt x i '0' System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()).equals("0") == false) {
				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum = sum + x.charAt(i) - '0';
				}
				
				System.out.println(sum);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()).equals("0") == false) {
				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum = sum + x.charAt(i) - '0';
				}
				
				System.out.println(sum);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()).equals("0") == false) {
				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum = sum + x.charAt(i) - '0';
				}
				
				System.out.println(sum);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}