from pprint import pprint

MOD = 10 ** 9 + 7
L = input()
nl = len(L)
dp = [[0 for _ in range(2)]
      for _ in range(nl + 1)]
dp[0][0] = 1

for i in range(1, nl + 1):
    li = i - 1

    # 小さいこと確定
    dp[i][1] = dp[i - 1][1] * 3 % MOD

    ############################
    if L[li] == '1':
        dp[i][1] += dp[i - 1][0]  # a, b 両方0

    # 当該桁まで =
    if L[li] == '1':
        dp[i][0] = dp[i - 1][0] * 2 % MOD  # a, b いずれか 1
    else:
        dp[i][0] = dp[i - 1][0]  # a, b 両方0

    dp[i][0] %= MOD
    dp[i][1] %= MOD

print(sum(dp[-1])%MOD) from pprint import pprint MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 L = input() L input() input nl = len(L) nl len(L) len L [0 for _ in range(2)]
      for _ in range(nl + 1) for _ in range(nl + 1) _ range(nl + 1) range nl + 1 nl 1 for _ in range(nl + 1) [0 for _ in range(2)] dp = [[0 for _ in range(2)]
      for _ in range(nl + 1)] dp [[0 for _ in range(2)]
      for _ in range(nl + 1)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 for i in range(1, nl + 1):
    li = i - 1

    # 小さいこと確定
    dp[i][1] = dp[i - 1][1] * 3 % MOD

    ############################
    if L[li] == '1':
        dp[i][1] += dp[i - 1][0]  # a, b 両方0

    # 当該桁まで =
    if L[li] == '1':
        dp[i][0] = dp[i - 1][0] * 2 % MOD  # a, b いずれか 1
    else:
        dp[i][0] = dp[i - 1][0]  # a, b 両方0

    dp[i][0] %= MOD
    dp[i][1] %= MOD i range(1, nl + 1) range 1 nl + 1 nl 1 li = i - 1 li i - 1 i 1 dp[i][1] = dp[i - 1][1] * 3 % MOD dp[i][1] [i] dp i 1 dp[i - 1][1] * 3 % MOD dp[i - 1][1] * 3 dp[i - 1][1] [i - 1] dp i - 1 i 1 1 3 MOD if L[li] == '1':
        dp[i][1] += dp[i - 1][0]  # a, b 両方0

    # 当該桁まで =
     L[li] == '1' L[li] L li '1' dp[i][1] += dp[i - 1][0] dp[i][1] [i] dp i 1 dp[i - 1][0] [i - 1] dp i - 1 i 1 0 if L[li] == '1':
        dp[i][0] = dp[i - 1][0] * 2 % MOD  # a, b いずれか 1
    else:
        dp[i][0] = dp[i - 1][0]  # a, b 両方0

     L[li] == '1' L[li] L li '1' dp[i][0] = dp[i - 1][0] * 2 % MOD dp[i][0] [i] dp i 0 dp[i - 1][0] * 2 % MOD dp[i - 1][0] * 2 dp[i - 1][0] [i - 1] dp i - 1 i 1 0 2 MOD dp[i][0] = dp[i - 1][0] dp[i][0] [i] dp i 0 dp[i - 1][0] [i - 1] dp i - 1 i 1 0 dp[i][0] %= MOD dp[i][0] [i] dp i 0 MOD dp[i][1] %= MOD dp[i][1] [i] dp i 1 MOD print(sum(dp[-1])%MOD) print sum(dp[-1])%MOD sum(dp[-1]) sum dp[-1] dp -1 MOD li = i - 1 i - 1 li L = input() input() L dp = [[0 for _ in range(2)]
      for _ in range(nl + 1)] [[0 for _ in range(2)]
      for _ in range(nl + 1)] dp MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD nl = len(L) len(L) nl
from pprint import pprint

MOD = 10 ** 9 + 7
L = input()
nl = len(L)
dp = [[0 for _ in range(2)]
      for _ in range(nl + 1)]
dp[0][0] = 1

for i in range(1, nl + 1):
    li = i - 1

    # 小さいこと確定
    dp[i][1] = dp[i - 1][1] * 3 % MOD

    ############################
    if L[li] == '1':
        dp[i][1] += dp[i - 1][0]  # a, b 両方0

    # 当該桁まで =
    if L[li] == '1':
        dp[i][0] = dp[i - 1][0] * 2 % MOD  # a, b いずれか 1
    else:
        dp[i][0] = dp[i - 1][0]  # a, b 両方0

    dp[i][0] %= MOD
    dp[i][1] %= MOD

print(sum(dp[-1])%MOD)
