L = input()
N = len(L)
mod = 10**9 + 7

dpT = [0]*N
dpF = [0]*N

dpT[0] = 1
dpF[0] = 2

for i in range(1, N):
  if L[i] == "1":
    dpT[i] = dpT[i-1] * 3 + dpF[i-1] * 1
    dpF[i] = dpF[i-1] * 2
    dpT[i] %= mod
    dpF[i] %= mod
  else:
    dpT[i] = dpT[i-1] * 3
    dpF[i] = dpF[i-1] * 1
    dpT[i] %= mod
    dpF[i] %= mod

print((dpT[-1]+dpF[-1])%mod)
#print(dpT, dpF) 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 dpT = [0]*N dpT [0]*N [0] 0 N dpF = [0]*N dpF [0]*N [0] 0 N dpT[0] = 1 dpT[0] dpT 0 1 dpF[0] = 2 dpF[0] dpF 0 2 for i in range(1, N):
  if L[i] == "1":
    dpT[i] = dpT[i-1] * 3 + dpF[i-1] * 1
    dpF[i] = dpF[i-1] * 2
    dpT[i] %= mod
    dpF[i] %= mod
  else:
    dpT[i] = dpT[i-1] * 3
    dpF[i] = dpF[i-1] * 1
    dpT[i] %= mod
    dpF[i] %= mod i range(1, N) range 1 N if L[i] == "1":
    dpT[i] = dpT[i-1] * 3 + dpF[i-1] * 1
    dpF[i] = dpF[i-1] * 2
    dpT[i] %= mod
    dpF[i] %= mod
  else:
    dpT[i] = dpT[i-1] * 3
    dpF[i] = dpF[i-1] * 1
    dpT[i] %= mod
    dpF[i] %= mod L[i] == "1" L[i] L i "1" dpT[i] = dpT[i-1] * 3 + dpF[i-1] * 1 dpT[i] dpT i dpT[i-1] * 3 + dpF[i-1] * 1 dpT[i-1] * 3 dpT[i-1] dpT i-1 i 1 3 dpF[i-1] * 1 dpF[i-1] dpF i-1 i 1 1 dpF[i] = dpF[i-1] * 2 dpF[i] dpF i dpF[i-1] * 2 dpF[i-1] dpF i-1 i 1 2 dpT[i] %= mod dpT[i] dpT i mod dpF[i] %= mod dpF[i] dpF i mod dpT[i] = dpT[i-1] * 3 dpT[i] dpT i dpT[i-1] * 3 dpT[i-1] dpT i-1 i 1 3 dpF[i] = dpF[i-1] * 1 dpF[i] dpF i dpF[i-1] * 1 dpF[i-1] dpF i-1 i 1 1 dpT[i] %= mod dpT[i] dpT i mod dpF[i] %= mod dpF[i] dpF i mod print((dpT[-1]+dpF[-1])%mod) print (dpT[-1]+dpF[-1])%mod dpT[-1]+dpF[-1] dpT[-1] dpT -1 dpF[-1] dpF -1 mod dpF = [0]*N [0]*N dpF dpT = [0]*N [0]*N dpT N = len(L) len(L) N L = input() input() L mod = 10**9 + 7 10**9 + 7 mod
L = input()
N = len(L)
mod = 10**9 + 7

dpT = [0]*N
dpF = [0]*N

dpT[0] = 1
dpF[0] = 2

for i in range(1, N):
  if L[i] == "1":
    dpT[i] = dpT[i-1] * 3 + dpF[i-1] * 1
    dpF[i] = dpF[i-1] * 2
    dpT[i] %= mod
    dpF[i] %= mod
  else:
    dpT[i] = dpT[i-1] * 3
    dpF[i] = dpF[i-1] * 1
    dpT[i] %= mod
    dpF[i] %= mod

print((dpT[-1]+dpF[-1])%mod)
#print(dpT, dpF)