let modulo = 1000000007
let (+@) a b = (a + b) mod modulo
let ( *@ ) a b = (a * b) mod modulo
let rec modpow a n =
  if n = 0 then 1
  else if n mod 2 = 1 then a *@ modpow a (n-1)
  else let h = modpow a (n/2) in h *@ h

let () =
  Scanf.scanf "%s" @@ fun s ->
  let n = String.length s in
  let s = Array.init n (fun i -> i, s.[i]) in
  let m, z =
    Array.fold_left (fun (m, z) (i, c) ->
      match c with
      | '0' -> (m, z)
      | _ (* '1' *) -> (2 *@ m, z +@ m *@ modpow 3 (n-1-i))
    ) (1, 0) s
  in
  Printf.printf "%d\n" (m +@ z)
  
