let () =
    let mm = 1000000000 + 7 in
    let main () =
        let l = read_line () in
        let s = String.length l in
        let rec loop i k acc =
            if i = s then acc else
                if l.[i] = '1' then loop (i + 1) ((k * 2) mod mm) ((acc * 3) mod mm)
                    else loop (i + 1) k (((acc - k + mm) * 3 + k) mod mm)
        in
        let n = loop 1 2 3 in
        Printf.printf "%d\n" n
    in
    main ()