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

class Main {
  public static void main(String args[]) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] n;
    int sum;
    try {
      while (true) {
        sum = 0;
        n = br.readLine().split("(?<=.)");
        if (Integer.parseInt(n[0]) == 0) break;
        for (int i = 0; i < n.length; i++) {
          sum += Integer.parseInt(n[i]);
        }
        System.out.println(sum);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
} import java.util.*; util.* java import java.io.*; io.* java class Main {
  public static void main(String args[]) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] n;
    int sum;
    try {
      while (true) {
        sum = 0;
        n = br.readLine().split("(?<=.)");
        if (Integer.parseInt(n[0]) == 0) break;
        for (int i = 0; i < n.length; i++) {
          sum += Integer.parseInt(n[i]);
        }
        System.out.println(sum);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
} Main public static void main(String args[]) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] n;
    int sum;
    try {
      while (true) {
        sum = 0;
        n = br.readLine().split("(?<=.)");
        if (Integer.parseInt(n[0]) == 0) break;
        for (int i = 0; i < n.length; i++) {
          sum += Integer.parseInt(n[i]);
        }
        System.out.println(sum);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  } main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] n;
    int sum;
    try {
      while (true) {
        sum = 0;
        n = br.readLine().split("(?<=.)");
        if (Integer.parseInt(n[0]) == 0) break;
        for (int i = 0; i < n.length; i++) {
          sum += Integer.parseInt(n[i]);
        }
        System.out.println(sum);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] n; n int sum; sum try {
      while (true) {
        sum = 0;
        n = br.readLine().split("(?<=.)");
        if (Integer.parseInt(n[0]) == 0) break;
        for (int i = 0; i < n.length; i++) {
          sum += Integer.parseInt(n[i]);
        }
        System.out.println(sum);
      }
    } catch (IOException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } IOException e {
      e.printStackTrace();
    } e.printStackTrace() e.printStackTrace e {
      while (true) {
        sum = 0;
        n = br.readLine().split("(?<=.)");
        if (Integer.parseInt(n[0]) == 0) break;
        for (int i = 0; i < n.length; i++) {
          sum += Integer.parseInt(n[i]);
        }
        System.out.println(sum);
      }
    } while (true) {
        sum = 0;
        n = br.readLine().split("(?<=.)");
        if (Integer.parseInt(n[0]) == 0) break;
        for (int i = 0; i < n.length; i++) {
          sum += Integer.parseInt(n[i]);
        }
        System.out.println(sum);
      } true {
        sum = 0;
        n = br.readLine().split("(?<=.)");
        if (Integer.parseInt(n[0]) == 0) break;
        for (int i = 0; i < n.length; i++) {
          sum += Integer.parseInt(n[i]);
        }
        System.out.println(sum);
      } sum = 0 sum 0 n = br.readLine().split("(?<=.)") n br.readLine().split("(?<=.)") br.readLine().split br.readLine() br.readLine br "(?<=.)" if (Integer.parseInt(n[0]) == 0) break; Integer.parseInt(n[0]) == 0 Integer.parseInt(n[0]) Integer.parseInt Integer n[0] n 0 0 break; for (int i = 0; i < n.length; i++) {
          sum += Integer.parseInt(n[i]);
        } int i = 0; int i = 0; i 0 i < n.length i n.length n n.length i++ i++ i {
          sum += Integer.parseInt(n[i]);
        } {
          sum += Integer.parseInt(n[i]);
        } sum += Integer.parseInt(n[i]) sum Integer.parseInt(n[i]) Integer.parseInt Integer n[i] n i System.out.println(sum) System.out.println System.out System System.out sum String args[] args
import java.util.*;
import java.io.*;

class Main {
  public static void main(String args[]) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] n;
    int sum;
    try {
      while (true) {
        sum = 0;
        n = br.readLine().split("(?<=.)");
        if (Integer.parseInt(n[0]) == 0) break;
        for (int i = 0; i < n.length; i++) {
          sum += Integer.parseInt(n[i]);
        }
        System.out.println(sum);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}