import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class App { public static void main(String[] args) throws Exception { // System.out.println("Hello, World!"); // ■標準入力 // Scannerクラス Scanner scanner = new Scanner(System.in); // nextLineメソッド String s = scanner.nextLine(); String[] sArray = s.split(""); List sList = Arrays.asList(sArray); List sIntList = new ArrayList<>(); sList.stream().forEach(h -> { Integer intS = Integer.valueOf(h); sIntList.add(intS); }); int total = sIntList.stream().mapToInt(val -> val).sum(); System.out.println(total); scanner.close(); } }