import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
BufferedReader input=new BufferedReader (new InputStreamReader (System.in));
    while(true)
        {
         
        int sum=0;
        String str=input.readLine();
        if(str.equals("0"))break;
        for(int i=0;i<str.length();i++)
            {
             
            sum+=str.charAt(i)-'0';
            }
        System.out.println(sum);
        }
    }
} import java.io.*; io.* java class Main
{
    public static void main(String args[])throws IOException
    {
BufferedReader input=new BufferedReader (new InputStreamReader (System.in));
    while(true)
        {
         
        int sum=0;
        String str=input.readLine();
        if(str.equals("0"))break;
        for(int i=0;i<str.length();i++)
            {
             
            sum+=str.charAt(i)-'0';
            }
        System.out.println(sum);
        }
    }
} Main public static void main(String args[])throws IOException
    {
BufferedReader input=new BufferedReader (new InputStreamReader (System.in));
    while(true)
        {
         
        int sum=0;
        String str=input.readLine();
        if(str.equals("0"))break;
        for(int i=0;i<str.length();i++)
            {
             
            sum+=str.charAt(i)-'0';
            }
        System.out.println(sum);
        }
    } main {
BufferedReader input=new BufferedReader (new InputStreamReader (System.in));
    while(true)
        {
         
        int sum=0;
        String str=input.readLine();
        if(str.equals("0"))break;
        for(int i=0;i<str.length();i++)
            {
             
            sum+=str.charAt(i)-'0';
            }
        System.out.println(sum);
        }
    } BufferedReader input=new BufferedReader (new InputStreamReader (System.in)); input new BufferedReader (new InputStreamReader (System.in)) while(true)
        {
         
        int sum=0;
        String str=input.readLine();
        if(str.equals("0"))break;
        for(int i=0;i<str.length();i++)
            {
             
            sum+=str.charAt(i)-'0';
            }
        System.out.println(sum);
        } true {
         
        int sum=0;
        String str=input.readLine();
        if(str.equals("0"))break;
        for(int i=0;i<str.length();i++)
            {
             
            sum+=str.charAt(i)-'0';
            }
        System.out.println(sum);
        } int sum=0; sum 0 String str=input.readLine(); str input.readLine() input.readLine input if(str.equals("0"))break; str.equals("0") str.equals str "0" break; for(int i=0;i<str.length();i++)
            {
             
            sum+=str.charAt(i)-'0';
            } int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
             
            sum+=str.charAt(i)-'0';
            } {
             
            sum+=str.charAt(i)-'0';
            } sum+=str.charAt(i)-'0' sum str.charAt(i)-'0' str.charAt(i) str.charAt str i '0' System.out.println(sum) System.out.println System.out System System.out sum String args[] args
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
BufferedReader input=new BufferedReader (new InputStreamReader (System.in));
    while(true)
        {
         
        int sum=0;
        String str=input.readLine();
        if(str.equals("0"))break;
        for(int i=0;i<str.length();i++)
            {
             
            sum+=str.charAt(i)-'0';
            }
        System.out.println(sum);
        }
    }
}