import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char[] arr = sc.next().toCharArray(); int n = arr.length; int[] base = new int[n]; for (int i = 0; i < n; i++) { base[i] = arr[i] - '0'; } int start = 0; long count = 0; while (start < n) { boolean next = false; for (int i = start; i < n; i++) { if (next) { base[i] += 10; } if (i == start && base[i] == 1) { start++; base[i] = 0; next = true; continue; } next = (base[i] % 2 == 1); base[i] /= 2; } if (next) { count++; } } System.out.println(count % 1004535809); } }