def main():
  L = str(input())
  dp = [[0, 0] for _ in range(len(L))]
  dp[0][0] = 1
  dp[0][1] = 2
  MOD = 10**9 + 7
  for i in range(1, len(L)):
    if L[i] == '1':
      dp[i][0] = 3*dp[i-1][0] + dp[i-1][1]
      dp[i][0] %= MOD
      dp[i][1] = 2*dp[i-1][1]
      dp[i][1] %= MOD
    else:
      dp[i][0] = 3*dp[i-1][0]
      dp[i][0] %= MOD
      dp[i][1] = dp[i-1][1]
  print((dp[-1][0] + dp[-1][1])%MOD)

if __name__ == "__main__":
  main() def main():
  L = str(input())
  dp = [[0, 0] for _ in range(len(L))]
  dp[0][0] = 1
  dp[0][1] = 2
  MOD = 10**9 + 7
  for i in range(1, len(L)):
    if L[i] == '1':
      dp[i][0] = 3*dp[i-1][0] + dp[i-1][1]
      dp[i][0] %= MOD
      dp[i][1] = 2*dp[i-1][1]
      dp[i][1] %= MOD
    else:
      dp[i][0] = 3*dp[i-1][0]
      dp[i][0] %= MOD
      dp[i][1] = dp[i-1][1]
  print((dp[-1][0] + dp[-1][1])%MOD) main L = str(input()) L str(input()) str input() input [0, 0] for _ in range(len(L)) for _ in range(len(L)) _ range(len(L)) range len(L) len L for _ in range(len(L)) [0, 0] 0 0 dp = [[0, 0] for _ in range(len(L))] dp [[0, 0] for _ in range(len(L))] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 dp[0][1] = 2 dp[0][1] [0] dp 0 1 2 MOD = 10**9 + 7 MOD 10**9 + 7 10**9 10 9 7 for i in range(1, len(L)):
    if L[i] == '1':
      dp[i][0] = 3*dp[i-1][0] + dp[i-1][1]
      dp[i][0] %= MOD
      dp[i][1] = 2*dp[i-1][1]
      dp[i][1] %= MOD
    else:
      dp[i][0] = 3*dp[i-1][0]
      dp[i][0] %= MOD
      dp[i][1] = dp[i-1][1]
   i range(1, len(L)) range 1 len(L) len L if L[i] == '1':
      dp[i][0] = 3*dp[i-1][0] + dp[i-1][1]
      dp[i][0] %= MOD
      dp[i][1] = 2*dp[i-1][1]
      dp[i][1] %= MOD
    else:
      dp[i][0] = 3*dp[i-1][0]
      dp[i][0] %= MOD
      dp[i][1] = dp[i-1][1]
   L[i] == '1' L[i] L i '1' dp[i][0] = 3*dp[i-1][0] + dp[i-1][1] dp[i][0] [i] dp i 0 3*dp[i-1][0] + dp[i-1][1] 3*dp[i-1][0] 3 dp[i-1][0] [i-1] dp i-1 i 1 0 dp[i-1][1] [i-1] dp i-1 i 1 1 dp[i][0] %= MOD dp[i][0] [i] dp i 0 MOD dp[i][1] = 2*dp[i-1][1] dp[i][1] [i] dp i 1 2*dp[i-1][1] 2 dp[i-1][1] [i-1] dp i-1 i 1 1 dp[i][1] %= MOD dp[i][1] [i] dp i 1 MOD dp[i][0] = 3*dp[i-1][0] dp[i][0] [i] dp i 0 3*dp[i-1][0] 3 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] = dp[i-1][1] dp[i][1] [i] dp i 1 dp[i-1][1] [i-1] dp i-1 i 1 1 print((dp[-1][0] + dp[-1][1])%MOD) print (dp[-1][0] + dp[-1][1])%MOD dp[-1][0] + dp[-1][1] dp[-1][0] [-1] dp -1 0 dp[-1][1] [-1] dp -1 1 MOD if __name__ == "__main__":
  main() __name__ == "__main__" __name__ "__main__" main() main def main():
  L = str(input())
  dp = [[0, 0] for _ in range(len(L))]
  dp[0][0] = 1
  dp[0][1] = 2
  MOD = 10**9 + 7
  for i in range(1, len(L)):
    if L[i] == '1':
      dp[i][0] = 3*dp[i-1][0] + dp[i-1][1]
      dp[i][0] %= MOD
      dp[i][1] = 2*dp[i-1][1]
      dp[i][1] %= MOD
    else:
      dp[i][0] = 3*dp[i-1][0]
      dp[i][0] %= MOD
      dp[i][1] = dp[i-1][1]
  print((dp[-1][0] + dp[-1][1])%MOD) def main():
  L = str(input())
  dp = [[0, 0] for _ in range(len(L))]
  dp[0][0] = 1
  dp[0][1] = 2
  MOD = 10**9 + 7
  for i in range(1, len(L)):
    if L[i] == '1':
      dp[i][0] = 3*dp[i-1][0] + dp[i-1][1]
      dp[i][0] %= MOD
      dp[i][1] = 2*dp[i-1][1]
      dp[i][1] %= MOD
    else:
      dp[i][0] = 3*dp[i-1][0]
      dp[i][0] %= MOD
      dp[i][1] = dp[i-1][1]
  print((dp[-1][0] + dp[-1][1])%MOD) main
def main():
  L = str(input())
  dp = [[0, 0] for _ in range(len(L))]
  dp[0][0] = 1
  dp[0][1] = 2
  MOD = 10**9 + 7
  for i in range(1, len(L)):
    if L[i] == '1':
      dp[i][0] = 3*dp[i-1][0] + dp[i-1][1]
      dp[i][0] %= MOD
      dp[i][1] = 2*dp[i-1][1]
      dp[i][1] %= MOD
    else:
      dp[i][0] = 3*dp[i-1][0]
      dp[i][0] %= MOD
      dp[i][1] = dp[i-1][1]
  print((dp[-1][0] + dp[-1][1])%MOD)

if __name__ == "__main__":
  main()