/* ITP1_8_B */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();

      while(true){
        String str = br.readLine();
        char[] input = str.toCharArray();
        if(input[0] == '0') break;

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

    }catch(Exception e){
      System.out.println(e);
    }
  }
} import java.io.*; io.* java class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();

      while(true){
        String str = br.readLine();
        char[] input = str.toCharArray();
        if(input[0] == '0') break;

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

    }catch(Exception e){
      System.out.println(e);
    }
  }
} Main public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();

      while(true){
        String str = br.readLine();
        char[] input = str.toCharArray();
        if(input[0] == '0') break;

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

    }catch(Exception e){
      System.out.println(e);
    }
  } main {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();

      while(true){
        String str = br.readLine();
        char[] input = str.toCharArray();
        if(input[0] == '0') break;

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

    }catch(Exception e){
      System.out.println(e);
    }
  } try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();

      while(true){
        String str = br.readLine();
        char[] input = str.toCharArray();
        if(input[0] == '0') break;

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

    }catch(Exception e){
      System.out.println(e);
    } catch(Exception e){
      System.out.println(e);
    } Exception e {
      System.out.println(e);
    } System.out.println(e) System.out.println System.out System System.out e {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();

      while(true){
        String str = br.readLine();
        char[] input = str.toCharArray();
        if(input[0] == '0') break;

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

    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while(true){
        String str = br.readLine();
        char[] input = str.toCharArray();
        if(input[0] == '0') break;

        int sum = 0;
        for(int i = 0; i < input.length; i++){
          sum += Character.getNumericValue(input[i]);
        }
        sb.append(sum).append("\n");
      } true {
        String str = br.readLine();
        char[] input = str.toCharArray();
        if(input[0] == '0') break;

        int sum = 0;
        for(int i = 0; i < input.length; i++){
          sum += Character.getNumericValue(input[i]);
        }
        sb.append(sum).append("\n");
      } String str = br.readLine(); str br.readLine() br.readLine br char[] input = str.toCharArray(); input str.toCharArray() str.toCharArray str if(input[0] == '0') break; input[0] == '0' input[0] input 0 '0' break; int sum = 0; sum 0 for(int i = 0; i < input.length; i++){
          sum += Character.getNumericValue(input[i]);
        } int i = 0; int i = 0; i 0 i < input.length i input.length input input.length i++ i++ i {
          sum += Character.getNumericValue(input[i]);
        } {
          sum += Character.getNumericValue(input[i]);
        } sum += Character.getNumericValue(input[i]) sum Character.getNumericValue(input[i]) Character.getNumericValue Character input[i] input i sb.append(sum).append("\n") sb.append(sum).append sb.append(sum) sb.append sb sum "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args
/* ITP1_8_B */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();

      while(true){
        String str = br.readLine();
        char[] input = str.toCharArray();
        if(input[0] == '0') break;

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

    }catch(Exception e){
      System.out.println(e);
    }
  }
}