// ITP1_8_B Sum of Numbers
import java.io.*;

class Main {

   public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         String str = br.readLine();
         char[] x = str.toCharArray();
         while (x[0] != '0') {
            int i = 0;
            int sum = 0;

            while (i < x.length) {
               sum += x[i++] - '0';
            }

            System.out.println(sum);
            str = br.readLine();
            x = str.toCharArray();
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }
} import java.io.*; io.* java class Main {

   public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         String str = br.readLine();
         char[] x = str.toCharArray();
         while (x[0] != '0') {
            int i = 0;
            int sum = 0;

            while (i < x.length) {
               sum += x[i++] - '0';
            }

            System.out.println(sum);
            str = br.readLine();
            x = str.toCharArray();
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }
} Main public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         String str = br.readLine();
         char[] x = str.toCharArray();
         while (x[0] != '0') {
            int i = 0;
            int sum = 0;

            while (i < x.length) {
               sum += x[i++] - '0';
            }

            System.out.println(sum);
            str = br.readLine();
            x = str.toCharArray();
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   } main {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         String str = br.readLine();
         char[] x = str.toCharArray();
         while (x[0] != '0') {
            int i = 0;
            int sum = 0;

            while (i < x.length) {
               sum += x[i++] - '0';
            }

            System.out.println(sum);
            str = br.readLine();
            x = str.toCharArray();
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   } try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         String str = br.readLine();
         char[] x = str.toCharArray();
         while (x[0] != '0') {
            int i = 0;
            int sum = 0;

            while (i < x.length) {
               sum += x[i++] - '0';
            }

            System.out.println(sum);
            str = br.readLine();
            x = str.toCharArray();
         }
      }

      catch (Exception e) {
         System.err.println(e);
      } catch (Exception e) {
         System.err.println(e);
      } Exception e {
         System.err.println(e);
      } System.err.println(e) System.err.println System.err System System.err e {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         String str = br.readLine();
         char[] x = str.toCharArray();
         while (x[0] != '0') {
            int i = 0;
            int sum = 0;

            while (i < x.length) {
               sum += x[i++] - '0';
            }

            System.out.println(sum);
            str = br.readLine();
            x = str.toCharArray();
         }
      } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str = br.readLine(); str br.readLine() br.readLine br char[] x = str.toCharArray(); x str.toCharArray() str.toCharArray str while (x[0] != '0') {
            int i = 0;
            int sum = 0;

            while (i < x.length) {
               sum += x[i++] - '0';
            }

            System.out.println(sum);
            str = br.readLine();
            x = str.toCharArray();
         } x[0] != '0' x[0] x 0 '0' {
            int i = 0;
            int sum = 0;

            while (i < x.length) {
               sum += x[i++] - '0';
            }

            System.out.println(sum);
            str = br.readLine();
            x = str.toCharArray();
         } int i = 0; i 0 int sum = 0; sum 0 while (i < x.length) {
               sum += x[i++] - '0';
            } i < x.length i x.length x x.length {
               sum += x[i++] - '0';
            } sum += x[i++] - '0' sum x[i++] - '0' x[i++] x i++ i '0' System.out.println(sum) System.out.println System.out System System.out sum str = br.readLine() str br.readLine() br.readLine br x = str.toCharArray() x str.toCharArray() str.toCharArray str String[] args args
// ITP1_8_B Sum of Numbers
import java.io.*;

class Main {

   public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         String str = br.readLine();
         char[] x = str.toCharArray();
         while (x[0] != '0') {
            int i = 0;
            int sum = 0;

            while (i < x.length) {
               sum += x[i++] - '0';
            }

            System.out.println(sum);
            str = br.readLine();
            x = str.toCharArray();
         }
      }

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