import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            if ("0".equals(line))
                break;
 
            char[] nums = line.toCharArray();
            int sum = 0;
            for (char num : nums) {
                sum += num - '0';
            }
            System.out.println(sum);
        }
    }
} import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            if ("0".equals(line))
                break;
 
            char[] nums = line.toCharArray();
            int sum = 0;
            for (char num : nums) {
                sum += num - '0';
            }
            System.out.println(sum);
        }
    }
} Main public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            if ("0".equals(line))
                break;
 
            char[] nums = line.toCharArray();
            int sum = 0;
            for (char num : nums) {
                sum += num - '0';
            }
            System.out.println(sum);
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            if ("0".equals(line))
                break;
 
            char[] nums = line.toCharArray();
            int sum = 0;
            for (char num : nums) {
                sum += num - '0';
            }
            System.out.println(sum);
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line; line while ((line = br.readLine()) != null) {
            if ("0".equals(line))
                break;
 
            char[] nums = line.toCharArray();
            int sum = 0;
            for (char num : nums) {
                sum += num - '0';
            }
            System.out.println(sum);
        } (line = br.readLine()) != null (line = br.readLine()) line br.readLine() br.readLine br null {
            if ("0".equals(line))
                break;
 
            char[] nums = line.toCharArray();
            int sum = 0;
            for (char num : nums) {
                sum += num - '0';
            }
            System.out.println(sum);
        } if ("0".equals(line))
                break; "0".equals(line) "0".equals "0" line break; char[] nums = line.toCharArray(); nums line.toCharArray() line.toCharArray line int sum = 0; sum 0 for (char num : nums) {
                sum += num - '0';
            } char num nums {
                sum += num - '0';
            } {
                sum += num - '0';
            } sum += num - '0' sum num - '0' num '0' System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            if ("0".equals(line))
                break;
 
            char[] nums = line.toCharArray();
            int sum = 0;
            for (char num : nums) {
                sum += num - '0';
            }
            System.out.println(sum);
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            if ("0".equals(line))
                break;
 
            char[] nums = line.toCharArray();
            int sum = 0;
            for (char num : nums) {
                sum += num - '0';
            }
            System.out.println(sum);
        }
    }
} Main
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            if ("0".equals(line))
                break;
 
            char[] nums = line.toCharArray();
            int sum = 0;
            for (char num : nums) {
                sum += num - '0';
            }
            System.out.println(sum);
        }
    }
}