# https://atcoder.jp/contests/abc129/tasks/abc129_e
MOD = (10**9) + 7
a = 1
b = 0
gets.chomp.bytes do |c|
  if c == 49
    b = (a + (b * 3)%MOD)%MOD
    a = (a * 2)%MOD
  else
    b = (b * 3)%MOD
  end
end

puts (a+b)%MOD