import java.util.Scanner;
import java.io.*;

public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 
        try { 
            Scanner sc = new Scanner(System.in);
        while(true){
            String str = reader.readLine();
            if(str.equals("0")){
                break;
            }
            int m=0;
            for(int i=0;i<str.length();i++){
            char c = str.charAt(i); 
                 if(c == '1'){
                     m=m+1;
                 }else if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 }
                 }
                 System.out.println(m);
                 }
                 } catch (IOException e) { 
                 System.out.println(e); 
                 }
        }
    } import java.util.Scanner; Scanner java.util import java.io.*; io.* java public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 
        try { 
            Scanner sc = new Scanner(System.in);
        while(true){
            String str = reader.readLine();
            if(str.equals("0")){
                break;
            }
            int m=0;
            for(int i=0;i<str.length();i++){
            char c = str.charAt(i); 
                 if(c == '1'){
                     m=m+1;
                 }else if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 }
                 }
                 System.out.println(m);
                 }
                 } catch (IOException e) { 
                 System.out.println(e); 
                 }
        }
    } Main public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 
        try { 
            Scanner sc = new Scanner(System.in);
        while(true){
            String str = reader.readLine();
            if(str.equals("0")){
                break;
            }
            int m=0;
            for(int i=0;i<str.length();i++){
            char c = str.charAt(i); 
                 if(c == '1'){
                     m=m+1;
                 }else if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 }
                 }
                 System.out.println(m);
                 }
                 } catch (IOException e) { 
                 System.out.println(e); 
                 }
        } main {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 
        try { 
            Scanner sc = new Scanner(System.in);
        while(true){
            String str = reader.readLine();
            if(str.equals("0")){
                break;
            }
            int m=0;
            for(int i=0;i<str.length();i++){
            char c = str.charAt(i); 
                 if(c == '1'){
                     m=m+1;
                 }else if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 }
                 }
                 System.out.println(m);
                 }
                 } catch (IOException e) { 
                 System.out.println(e); 
                 }
        } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) try { 
            Scanner sc = new Scanner(System.in);
        while(true){
            String str = reader.readLine();
            if(str.equals("0")){
                break;
            }
            int m=0;
            for(int i=0;i<str.length();i++){
            char c = str.charAt(i); 
                 if(c == '1'){
                     m=m+1;
                 }else if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 }
                 }
                 System.out.println(m);
                 }
                 } catch (IOException e) { 
                 System.out.println(e); 
                 } catch (IOException e) { 
                 System.out.println(e); 
                 } IOException e { 
                 System.out.println(e); 
                 } System.out.println(e) System.out.println System.out System System.out e { 
            Scanner sc = new Scanner(System.in);
        while(true){
            String str = reader.readLine();
            if(str.equals("0")){
                break;
            }
            int m=0;
            for(int i=0;i<str.length();i++){
            char c = str.charAt(i); 
                 if(c == '1'){
                     m=m+1;
                 }else if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 }
                 }
                 System.out.println(m);
                 }
                 } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
            String str = reader.readLine();
            if(str.equals("0")){
                break;
            }
            int m=0;
            for(int i=0;i<str.length();i++){
            char c = str.charAt(i); 
                 if(c == '1'){
                     m=m+1;
                 }else if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 }
                 }
                 System.out.println(m);
                 } true {
            String str = reader.readLine();
            if(str.equals("0")){
                break;
            }
            int m=0;
            for(int i=0;i<str.length();i++){
            char c = str.charAt(i); 
                 if(c == '1'){
                     m=m+1;
                 }else if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 }
                 }
                 System.out.println(m);
                 } String str = reader.readLine(); str reader.readLine() reader.readLine reader if(str.equals("0")){
                break;
            } str.equals("0") str.equals str "0" {
                break;
            } break; int m=0; m 0 for(int i=0;i<str.length();i++){
            char c = str.charAt(i); 
                 if(c == '1'){
                     m=m+1;
                 }else if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 }
                 } int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
            char c = str.charAt(i); 
                 if(c == '1'){
                     m=m+1;
                 }else if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 }
                 } {
            char c = str.charAt(i); 
                 if(c == '1'){
                     m=m+1;
                 }else if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 }
                 } char c = str.charAt(i); c str.charAt(i) str.charAt str i if(c == '1'){
                     m=m+1;
                 }else if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 } c == '1' c '1' {
                     m=m+1;
                 } m=m+1 m m+1 m 1 if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 } c == '2' c '2' {
                     m=m+2;
                 } m=m+2 m m+2 m 2 if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 } c == '3' c '3' {
                     m=m+3;
                 } m=m+3 m m+3 m 3 if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 } c == '4' c '4' {
                     m=m+4;
                 } m=m+4 m m+4 m 4 if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 } c == '5' c '5' {
                     m=m+5;
                 } m=m+5 m m+5 m 5 if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 } c == '6' c '6' {
                     m=m+6;
                 } m=m+6 m m+6 m 6 if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 } c == '7' c '7' {
                     m=m+7;
                 } m=m+7 m m+7 m 7 if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 } c == '8' c '8' {
                     m=m+8;
                 } m=m+8 m m+8 m 8 if(c == '9'){
                     m=m+9;
                 } c == '9' c '9' {
                     m=m+9;
                 } m=m+9 m m+9 m 9 System.out.println(m) System.out.println System.out System System.out m String[] args args public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 
        try { 
            Scanner sc = new Scanner(System.in);
        while(true){
            String str = reader.readLine();
            if(str.equals("0")){
                break;
            }
            int m=0;
            for(int i=0;i<str.length();i++){
            char c = str.charAt(i); 
                 if(c == '1'){
                     m=m+1;
                 }else if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 }
                 }
                 System.out.println(m);
                 }
                 } catch (IOException e) { 
                 System.out.println(e); 
                 }
        }
    } public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 
        try { 
            Scanner sc = new Scanner(System.in);
        while(true){
            String str = reader.readLine();
            if(str.equals("0")){
                break;
            }
            int m=0;
            for(int i=0;i<str.length();i++){
            char c = str.charAt(i); 
                 if(c == '1'){
                     m=m+1;
                 }else if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 }
                 }
                 System.out.println(m);
                 }
                 } catch (IOException e) { 
                 System.out.println(e); 
                 }
        }
    } Main
import java.util.Scanner;
import java.io.*;

public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 
        try { 
            Scanner sc = new Scanner(System.in);
        while(true){
            String str = reader.readLine();
            if(str.equals("0")){
                break;
            }
            int m=0;
            for(int i=0;i<str.length();i++){
            char c = str.charAt(i); 
                 if(c == '1'){
                     m=m+1;
                 }else if(c == '2'){
                     m=m+2;
                 }else if(c == '3'){
                     m=m+3;
                 }else if(c == '4'){
                     m=m+4;
                 }else if(c == '5'){
                     m=m+5;
                 }else if(c == '6'){
                     m=m+6;
                 }else if(c == '7'){
                     m=m+7;
                 }else if(c == '8'){
                     m=m+8;
                 }else if(c == '9'){
                     m=m+9;
                 }
                 }
                 System.out.println(m);
                 }
                 } catch (IOException e) { 
                 System.out.println(e); 
                 }
        }
    }
