import sys
sys.setrecursionlimit(10**7)

l=input()
n = len(l)
mod = 10**9+7

p3 = [1]
for _ in range(len(l)+5):
    p3.append((p3[-1]*3)%mod)

def dfs(k,f):
    if k == n:
        return 1
    if not f:
        return p3[n-k]
    if l[k] == "1":
        return (dfs(k+1,False)+dfs(k+1,True)*2)%mod
    else:
        return dfs(k+1,True)%mod

print(dfs(0,True)) import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 l=input() l input() input n = len(l) n len(l) len l mod = 10**9+7 mod 10**9+7 10**9 10 9 7 p3 = [1] p3 [1] 1 for _ in range(len(l)+5):
    p3.append((p3[-1]*3)%mod) _ range(len(l)+5) range len(l)+5 len(l) len l 5 p3.append((p3[-1]*3)%mod) p3.append p3 append (p3[-1]*3)%mod p3[-1]*3 p3[-1] p3 -1 3 mod def dfs(k,f):
    if k == n:
        return 1
    if not f:
        return p3[n-k]
    if l[k] == "1":
        return (dfs(k+1,False)+dfs(k+1,True)*2)%mod
    else:
        return dfs(k+1,True)%mod dfs if k == n:
        return 1
     k == n k n return 1 1 if not f:
        return p3[n-k]
     not f f return p3[n-k] p3[n-k] p3 n-k n k if l[k] == "1":
        return (dfs(k+1,False)+dfs(k+1,True)*2)%mod
    else:
        return dfs(k+1,True)%mod l[k] == "1" l[k] l k "1" return (dfs(k+1,False)+dfs(k+1,True)*2)%mod (dfs(k+1,False)+dfs(k+1,True)*2)%mod dfs(k+1,False)+dfs(k+1,True)*2 dfs(k+1,False) dfs k+1 k 1 False dfs(k+1,True)*2 dfs(k+1,True) dfs k+1 k 1 True 2 mod return dfs(k+1,True)%mod dfs(k+1,True)%mod dfs(k+1,True) dfs k+1 k 1 True mod k k f f print(dfs(0,True)) print dfs(0,True) dfs 0 True p3 = [1] [1] p3 mod = 10**9+7 10**9+7 mod def dfs(k,f):
    if k == n:
        return 1
    if not f:
        return p3[n-k]
    if l[k] == "1":
        return (dfs(k+1,False)+dfs(k+1,True)*2)%mod
    else:
        return dfs(k+1,True)%mod def dfs(k,f):
    if k == n:
        return 1
    if not f:
        return p3[n-k]
    if l[k] == "1":
        return (dfs(k+1,False)+dfs(k+1,True)*2)%mod
    else:
        return dfs(k+1,True)%mod dfs n = len(l) len(l) n l=input() input() l
import sys
sys.setrecursionlimit(10**7)

l=input()
n = len(l)
mod = 10**9+7

p3 = [1]
for _ in range(len(l)+5):
    p3.append((p3[-1]*3)%mod)

def dfs(k,f):
    if k == n:
        return 1
    if not f:
        return p3[n-k]
    if l[k] == "1":
        return (dfs(k+1,False)+dfs(k+1,True)*2)%mod
    else:
        return dfs(k+1,True)%mod

print(dfs(0,True))