local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max
local mab = math.abs
local mod = 1000000007
local function bmul(x, y)
  local x0, y0 = x % 31623, y % 31623
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end

local function modpow(src, pow)
  local res = 1
  while (0 < pow) do
    if (pow % 2 == 1) then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = mfl(pow / 2)
  end
  return res;
end

local str = io.read()
local n = #str
local t = {}
local a = {}
for i = 1, n do
  t[i] = tonumber(str:sub(n + 1 - i, n + 1 - i))
  a[i] = 0
end
a[1] = t[1] == 1 and 3 or 1
for i = 2, n do
  if t[i] == 0 then
    a[i] = a[i - 1]
  else
    a[i] = (modpow(3, i - 1) + bmul(2, a[i - 1])) % mod
  end
end
print(a[n])
