import java.io.*; import java.math.*; public class Main_yukicoder381_1 { public static void main(String[] args) { Printer pr = new Printer(System.out); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String n; try { n = br.readLine(); } catch (IOException e) { pr.close(); throw new IllegalStateException(); } // int du = 10_000; int du = 0x1 << 15; BigInteger bdu = BigInteger.TEN; for (int i = 0; i < 15; i++) { bdu = bdu.multiply(bdu); } int m = n.length() % du; BigInteger bn; if (m == 0) { bn = BigInteger.ZERO; } else { bn = new BigInteger(n.substring(0, m)); } int loop = n.length() / du; for (int i = 0; i < loop; i++) { String stmp = n.substring(m + i * du, m + (i + 1) * du); BigInteger btmp = new BigInteger(stmp); bn = bn.multiply(bdu).add(btmp); } pr.println(bn.bitCount() % 1_004_535_809); pr.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }