MOD = 1000000007
def power(a, b):
	if b == 0:
		return 1
	elif b == 1:
		return a % MOD
	elif b % 2 == 0:
		return (power(a, b//2) ** 2) % MOD
	else:
		return (power(a, b//2) ** 2 * a) % MOD
 
L = input()
N = len(L)
ans = 0
cou = 0
for i in range(N):
    if L[i] == "1":
        if i == 0:
            ans += (power(3, N-1-i) + 2) * (power(2, cou))
            ans %= MOD
            cou += 1
        else:
            ans += (power(3, N-1-i) + 1) * (power(2, cou))
            ans %= MOD
            cou += 1
print(ans) MOD = 1000000007 MOD 1000000007 def power(a, b):
	if b == 0:
		return 1
	elif b == 1:
		return a % MOD
	elif b % 2 == 0:
		return (power(a, b//2) ** 2) % MOD
	else:
		return (power(a, b//2) ** 2 * a) % MOD
  power if b == 0:
		return 1
	elif b == 1:
		return a % MOD
	elif b % 2 == 0:
		return (power(a, b//2) ** 2) % MOD
	else:
		return (power(a, b//2) ** 2 * a) % MOD
  b == 0 b 0 return 1 1 elif b == 1:
		return a % MOD
	 b == 1 b 1 return a % MOD a % MOD a MOD elif b % 2 == 0:
		return (power(a, b//2) ** 2) % MOD
	 b % 2 == 0 b % 2 b 2 0 return (power(a, b//2) ** 2) % MOD (power(a, b//2) ** 2) % MOD power(a, b//2) ** 2 power(a, b//2) power a b//2 b 2 2 MOD return (power(a, b//2) ** 2 * a) % MOD (power(a, b//2) ** 2 * a) % MOD power(a, b//2) ** 2 * a power(a, b//2) ** 2 power(a, b//2) power a b//2 b 2 2 a MOD a a b b L = input() L input() input N = len(L) N len(L) len L ans = 0 ans 0 cou = 0 cou 0 for i in range(N):
    if L[i] == "1":
        if i == 0:
            ans += (power(3, N-1-i) + 2) * (power(2, cou))
            ans %= MOD
            cou += 1
        else:
            ans += (power(3, N-1-i) + 1) * (power(2, cou))
            ans %= MOD
            cou += 1 i range(N) range N if L[i] == "1":
        if i == 0:
            ans += (power(3, N-1-i) + 2) * (power(2, cou))
            ans %= MOD
            cou += 1
        else:
            ans += (power(3, N-1-i) + 1) * (power(2, cou))
            ans %= MOD
            cou += 1 L[i] == "1" L[i] L i "1" if i == 0:
            ans += (power(3, N-1-i) + 2) * (power(2, cou))
            ans %= MOD
            cou += 1
        else:
            ans += (power(3, N-1-i) + 1) * (power(2, cou))
            ans %= MOD
            cou += 1 i == 0 i 0 ans += (power(3, N-1-i) + 2) * (power(2, cou)) ans (power(3, N-1-i) + 2) * (power(2, cou)) power(3, N-1-i) + 2 power(3, N-1-i) power 3 N-1-i N-1 N 1 i 2 power(2, cou) power 2 cou ans %= MOD ans MOD cou += 1 cou 1 ans += (power(3, N-1-i) + 1) * (power(2, cou)) ans (power(3, N-1-i) + 1) * (power(2, cou)) power(3, N-1-i) + 1 power(3, N-1-i) power 3 N-1-i N-1 N 1 i 1 power(2, cou) power 2 cou ans %= MOD ans MOD cou += 1 cou 1 print(ans) print ans L = input() input() L ans = 0 0 ans ans %= MOD MOD ans def power(a, b):
	if b == 0:
		return 1
	elif b == 1:
		return a % MOD
	elif b % 2 == 0:
		return (power(a, b//2) ** 2) % MOD
	else:
		return (power(a, b//2) ** 2 * a) % MOD
  def power(a, b):
	if b == 0:
		return 1
	elif b == 1:
		return a % MOD
	elif b % 2 == 0:
		return (power(a, b//2) ** 2) % MOD
	else:
		return (power(a, b//2) ** 2 * a) % MOD
  power ans += (power(3, N-1-i) + 2) * (power(2, cou)) (power(3, N-1-i) + 2) * (power(2, cou)) ans ans %= MOD MOD ans N = len(L) len(L) N cou += 1 1 cou MOD = 1000000007 1000000007 MOD cou = 0 0 cou cou += 1 1 cou ans += (power(3, N-1-i) + 1) * (power(2, cou)) (power(3, N-1-i) + 1) * (power(2, cou)) ans
MOD = 1000000007
def power(a, b):
	if b == 0:
		return 1
	elif b == 1:
		return a % MOD
	elif b % 2 == 0:
		return (power(a, b//2) ** 2) % MOD
	else:
		return (power(a, b//2) ** 2 * a) % MOD
 
L = input()
N = len(L)
ans = 0
cou = 0
for i in range(N):
    if L[i] == "1":
        if i == 0:
            ans += (power(3, N-1-i) + 2) * (power(2, cou))
            ans %= MOD
            cou += 1
        else:
            ans += (power(3, N-1-i) + 1) * (power(2, cou))
            ans %= MOD
            cou += 1
print(ans)