MOD = 10 ** 9 + 7


def main():
  L = input().strip()
  l = len(L)
  assert l > 0

  dp1 = [-1] * l
  dp2 = [-1] * l
  dp1[0] = 1
  dp2[0] = 2
  for k in range(1, l):
    dp1[k] = dp1[k - 1] * 3 % MOD

    if L[k] == '1':
      dp1[k] += dp2[k - 1]
      dp2[k] = dp2[k - 1] * 2 % MOD
    else:
      dp2[k] = dp2[k - 1]

  return (dp1[-1] + dp2[-1]) % MOD


if __name__ == '__main__':
  print(main()) MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 def main():
  L = input().strip()
  l = len(L)
  assert l > 0

  dp1 = [-1] * l
  dp2 = [-1] * l
  dp1[0] = 1
  dp2[0] = 2
  for k in range(1, l):
    dp1[k] = dp1[k - 1] * 3 % MOD

    if L[k] == '1':
      dp1[k] += dp2[k - 1]
      dp2[k] = dp2[k - 1] * 2 % MOD
    else:
      dp2[k] = dp2[k - 1]

  return (dp1[-1] + dp2[-1]) % MOD main L = input().strip() L input().strip() ().strip () input strip l = len(L) l len(L) len L assert l > 0 l > 0 l 0 dp1 = [-1] * l dp1 [-1] * l [-1] -1 l dp2 = [-1] * l dp2 [-1] * l [-1] -1 l dp1[0] = 1 dp1[0] dp1 0 1 dp2[0] = 2 dp2[0] dp2 0 2 for k in range(1, l):
    dp1[k] = dp1[k - 1] * 3 % MOD

    if L[k] == '1':
      dp1[k] += dp2[k - 1]
      dp2[k] = dp2[k - 1] * 2 % MOD
    else:
      dp2[k] = dp2[k - 1]

   k range(1, l) range 1 l dp1[k] = dp1[k - 1] * 3 % MOD dp1[k] dp1 k dp1[k - 1] * 3 % MOD dp1[k - 1] * 3 dp1[k - 1] dp1 k - 1 k 1 3 MOD if L[k] == '1':
      dp1[k] += dp2[k - 1]
      dp2[k] = dp2[k - 1] * 2 % MOD
    else:
      dp2[k] = dp2[k - 1]

   L[k] == '1' L[k] L k '1' dp1[k] += dp2[k - 1] dp1[k] dp1 k dp2[k - 1] dp2 k - 1 k 1 dp2[k] = dp2[k - 1] * 2 % MOD dp2[k] dp2 k dp2[k - 1] * 2 % MOD dp2[k - 1] * 2 dp2[k - 1] dp2 k - 1 k 1 2 MOD dp2[k] = dp2[k - 1] dp2[k] dp2 k dp2[k - 1] dp2 k - 1 k 1 return (dp1[-1] + dp2[-1]) % MOD (dp1[-1] + dp2[-1]) % MOD dp1[-1] + dp2[-1] dp1[-1] dp1 -1 dp2[-1] dp2 -1 MOD if __name__ == '__main__':
  print(main()) __name__ == '__main__' __name__ '__main__' print(main()) print main() main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD def main():
  L = input().strip()
  l = len(L)
  assert l > 0

  dp1 = [-1] * l
  dp2 = [-1] * l
  dp1[0] = 1
  dp2[0] = 2
  for k in range(1, l):
    dp1[k] = dp1[k - 1] * 3 % MOD

    if L[k] == '1':
      dp1[k] += dp2[k - 1]
      dp2[k] = dp2[k - 1] * 2 % MOD
    else:
      dp2[k] = dp2[k - 1]

  return (dp1[-1] + dp2[-1]) % MOD def main():
  L = input().strip()
  l = len(L)
  assert l > 0

  dp1 = [-1] * l
  dp2 = [-1] * l
  dp1[0] = 1
  dp2[0] = 2
  for k in range(1, l):
    dp1[k] = dp1[k - 1] * 3 % MOD

    if L[k] == '1':
      dp1[k] += dp2[k - 1]
      dp2[k] = dp2[k - 1] * 2 % MOD
    else:
      dp2[k] = dp2[k - 1]

  return (dp1[-1] + dp2[-1]) % MOD main
MOD = 10 ** 9 + 7


def main():
  L = input().strip()
  l = len(L)
  assert l > 0

  dp1 = [-1] * l
  dp2 = [-1] * l
  dp1[0] = 1
  dp2[0] = 2
  for k in range(1, l):
    dp1[k] = dp1[k - 1] * 3 % MOD

    if L[k] == '1':
      dp1[k] += dp2[k - 1]
      dp2[k] = dp2[k - 1] * 2 % MOD
    else:
      dp2[k] = dp2[k - 1]

  return (dp1[-1] + dp2[-1]) % MOD


if __name__ == '__main__':
  print(main())