l = gets.chomp
n = l.size
M = 10 ** 9 + 7

def pow(x, n)
    n == 0 ? 1 : (n.odd? ? x : 1) * pow(x ** 2 % M, n / 2) % M
end

fac = Array.new(n+1, 1)
1.upto(n) {|i| fac[i] = fac[i-1] * i % M}

rfac = Array.new(n+1)
rfac[-1] = pow(fac[-1], M - 2)
(n-1).downto(0) {|i| rfac[i] = rfac[i+1] * (i+1) % M}

ans = 0
t = 1
n.times do |i|
    next if l[i] == ?0
    ans = (ans + pow(3, n-i-1) * t % M) % M
    t = t * 2 % M
end

p (ans + t) % M