# E - Sum Equals Xor
# https://atcoder.jp/contests/abc129/tasks/abc129_e

MOD = 10 ** 9 + 7

L = input()
N = len(L)

# dp[i][j]= 上から i 桁目までを決めて、その桁までが (a, b) = [(0,0),(0,1),(1,0)] の3通りから選ばれていて、
# a+b が L より小さいことが確定している(j=1)/していない(j=0)ような選び方の個数
dp = [[0] * 2 for _ in range(N + 1)]
dp[0][0] = 1

for i, s in enumerate(L):
  dp[i + 1][0] = dp[i][0] * 2 if int(s) else dp[i][0] 
  dp[i + 1][1] = dp[i][0] if int(s) else 0
  dp[i + 1][1] += dp[i][1] * 3
  dp[i + 1][0] %= MOD
  dp[i + 1][1] %= MOD

print(sum(dp[N]) % MOD) MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 L = input() L input() input N = len(L) N len(L) len L [0] * 2 for _ in range(N + 1) for _ in range(N + 1) _ range(N + 1) range N + 1 N 1 for _ in range(N + 1) [0] * 2 [0] 0 2 dp = [[0] * 2 for _ in range(N + 1)] dp [[0] * 2 for _ in range(N + 1)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 for i, s in enumerate(L):
  dp[i + 1][0] = dp[i][0] * 2 if int(s) else dp[i][0] 
  dp[i + 1][1] = dp[i][0] if int(s) else 0
  dp[i + 1][1] += dp[i][1] * 3
  dp[i + 1][0] %= MOD
  dp[i + 1][1] %= MOD i s enumerate(L) enumerate L dp[i + 1][0] = dp[i][0] * 2 if int(s) else dp[i][0] dp[i + 1][0] [i + 1] dp i + 1 i 1 0 dp[i][0] * 2 if int(s) else dp[i][0] int(s) int s dp[i][0] * 2 dp[i][0] [i] dp i 0 2 dp[i][0] [i] dp i 0 dp[i + 1][1] = dp[i][0] if int(s) else 0 dp[i + 1][1] [i + 1] dp i + 1 i 1 1 dp[i][0] if int(s) else 0 int(s) int s dp[i][0] [i] dp i 0 0 dp[i + 1][1] += dp[i][1] * 3 dp[i + 1][1] [i + 1] dp i + 1 i 1 1 dp[i][1] * 3 dp[i][1] [i] dp i 1 3 dp[i + 1][0] %= MOD dp[i + 1][0] [i + 1] dp i + 1 i 1 0 MOD dp[i + 1][1] %= MOD dp[i + 1][1] [i + 1] dp i + 1 i 1 1 MOD print(sum(dp[N]) % MOD) print sum(dp[N]) % MOD sum(dp[N]) sum dp[N] dp N MOD MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD dp = [[0] * 2 for _ in range(N + 1)] [[0] * 2 for _ in range(N + 1)] dp N = len(L) len(L) N L = input() input() L
# E - Sum Equals Xor
# https://atcoder.jp/contests/abc129/tasks/abc129_e

MOD = 10 ** 9 + 7

L = input()
N = len(L)

# dp[i][j]= 上から i 桁目までを決めて、その桁までが (a, b) = [(0,0),(0,1),(1,0)] の3通りから選ばれていて、
# a+b が L より小さいことが確定している(j=1)/していない(j=0)ような選び方の個数
dp = [[0] * 2 for _ in range(N + 1)]
dp[0][0] = 1

for i, s in enumerate(L):
  dp[i + 1][0] = dp[i][0] * 2 if int(s) else dp[i][0] 
  dp[i + 1][1] = dp[i][0] if int(s) else 0
  dp[i + 1][1] += dp[i][1] * 3
  dp[i + 1][0] %= MOD
  dp[i + 1][1] %= MOD

print(sum(dp[N]) % MOD)