import Data.List
import qualified Data.Vector as V

main = getLine>>=print.solve

solve l = go 0 l
  where
  len = length l
  go _ [] = 1
  go i ('0':l) = go (i+1) l
  go i ('1':l) = 2 *% go (i+1) l +% pow3 V.! (len-i-1)

mo = 1000000007
infixl 6 *%
infixl 5 +%
a +% b = (a + b) `mod` mo
a *% b = (a * b) `mod` mo
pow3 = V.fromListN 100000 $ 1 : iterate (*%3) 3