import sys
sys.setrecursionlimit(10000000)
import math
import bisect
def input():
    return sys.stdin.readline()[:-1]

l = input()
mod = 10**9+7
from collections import deque
l = deque(l)

def llo(st):
    if len(st)==1 and st[0]=="0":
        return 1
    elif len(st)==1 and st[0]=="1":
        return 3
    tmp = st.popleft()
    if tmp=="0":
        return llo(st)
    else:
        return (pow(3,len(st),mod) + 2*llo(st))%mod



if "0" not in l:
    print(pow(3,len(l),mod))
else:
    ans = llo(l)
    print(ans) import sys sys sys.setrecursionlimit(10000000) sys.setrecursionlimit sys setrecursionlimit 10000000 import math math import bisect bisect def input():
    return sys.stdin.readline()[:-1] input return sys.stdin.readline()[:-1] sys.stdin.readline()[:-1] sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline :-1 -1 l = input() l input() input mod = 10**9+7 mod 10**9+7 10**9 10 9 7 from collections import deque l = deque(l) l deque(l) deque l def llo(st):
    if len(st)==1 and st[0]=="0":
        return 1
    elif len(st)==1 and st[0]=="1":
        return 3
    tmp = st.popleft()
    if tmp=="0":
        return llo(st)
    else:
        return (pow(3,len(st),mod) + 2*llo(st))%mod llo if len(st)==1 and st[0]=="0":
        return 1
    elif len(st)==1 and st[0]=="1":
        return 3
     len(st)==1 and st[0]=="0" len(st)==1 len(st) len st 1 st[0]=="0" st[0] st 0 "0" return 1 1 elif len(st)==1 and st[0]=="1":
        return 3
     len(st)==1 and st[0]=="1" len(st)==1 len(st) len st 1 st[0]=="1" st[0] st 0 "1" return 3 3 tmp = st.popleft() tmp st.popleft() st.popleft st popleft if tmp=="0":
        return llo(st)
    else:
        return (pow(3,len(st),mod) + 2*llo(st))%mod tmp=="0" tmp "0" return llo(st) llo(st) llo st return (pow(3,len(st),mod) + 2*llo(st))%mod (pow(3,len(st),mod) + 2*llo(st))%mod pow(3,len(st),mod) + 2*llo(st) pow(3,len(st),mod) pow 3 len(st) len st mod 2*llo(st) 2 llo(st) llo st mod st st if "0" not in l:
    print(pow(3,len(l),mod))
else:
    ans = llo(l)
    print(ans) "0" not in l "0" l print(pow(3,len(l),mod)) print pow(3,len(l),mod) pow 3 len(l) len l mod ans = llo(l) ans llo(l) llo l print(ans) print ans mod = 10**9+7 10**9+7 mod l = deque(l) deque(l) l l = input() input() l ans = llo(l) llo(l) ans def input():
    return sys.stdin.readline()[:-1] def input():
    return sys.stdin.readline()[:-1] input def llo(st):
    if len(st)==1 and st[0]=="0":
        return 1
    elif len(st)==1 and st[0]=="1":
        return 3
    tmp = st.popleft()
    if tmp=="0":
        return llo(st)
    else:
        return (pow(3,len(st),mod) + 2*llo(st))%mod def llo(st):
    if len(st)==1 and st[0]=="0":
        return 1
    elif len(st)==1 and st[0]=="1":
        return 3
    tmp = st.popleft()
    if tmp=="0":
        return llo(st)
    else:
        return (pow(3,len(st),mod) + 2*llo(st))%mod llo
import sys
sys.setrecursionlimit(10000000)
import math
import bisect
def input():
    return sys.stdin.readline()[:-1]

l = input()
mod = 10**9+7
from collections import deque
l = deque(l)

def llo(st):
    if len(st)==1 and st[0]=="0":
        return 1
    elif len(st)==1 and st[0]=="1":
        return 3
    tmp = st.popleft()
    if tmp=="0":
        return llo(st)
    else:
        return (pow(3,len(st),mod) + 2*llo(st))%mod



if "0" not in l:
    print(pow(3,len(l),mod))
else:
    ans = llo(l)
    print(ans)
