def powmod(x, n,mod):
  if n == 0:
   return 1
  K = 1
  while n > 1:
   if n % 2 != 0:
    K = K * x%mod
    x = x ** 2%mod
    n = (n - 1) // 2
   else:
    x = x ** 2%mod
    n = n // 2%mod

  return K * x # 指数を割り続け n が 1 に至ったら終了
L=input()
S=len(L)-1
if S==0:
 print(3)
else:
 ans=1
 ct=0
 for i in range(S+1):
  if int(L[i])==1:
   ans+=((powmod(3, S-i,10**9+7)+1)*powmod(2, ct,10**9+7))%(10**9+7)
   ans%=(10**9+7)
   ct+=1
 print(ans) def powmod(x, n,mod):
  if n == 0:
   return 1
  K = 1
  while n > 1:
   if n % 2 != 0:
    K = K * x%mod
    x = x ** 2%mod
    n = (n - 1) // 2
   else:
    x = x ** 2%mod
    n = n // 2%mod

  return K * x # 指数を割り続け n が 1 に至ったら終了 powmod if n == 0:
   return 1
   n == 0 n 0 return 1 1 K = 1 K 1 while n > 1:
   if n % 2 != 0:
    K = K * x%mod
    x = x ** 2%mod
    n = (n - 1) // 2
   else:
    x = x ** 2%mod
    n = n // 2%mod

   n > 1 n 1 if n % 2 != 0:
    K = K * x%mod
    x = x ** 2%mod
    n = (n - 1) // 2
   else:
    x = x ** 2%mod
    n = n // 2%mod

   n % 2 != 0 n % 2 n 2 0 K = K * x%mod K K * x%mod K * x K x mod x = x ** 2%mod x x ** 2%mod x ** 2 x 2 mod n = (n - 1) // 2 n (n - 1) // 2 n - 1 n 1 2 x = x ** 2%mod x x ** 2%mod x ** 2 x 2 mod n = n // 2%mod n n // 2%mod n // 2 n 2 mod return K * x K * x K x x x n n mod mod L=input() L input() input S=len(L)-1 S len(L)-1 len(L) len L 1 if S==0:
 print(3)
else:
 ans=1
 ct=0
 for i in range(S+1):
  if int(L[i])==1:
   ans+=((powmod(3, S-i,10**9+7)+1)*powmod(2, ct,10**9+7))%(10**9+7)
   ans%=(10**9+7)
   ct+=1
 print(ans) S==0 S 0 print(3) print 3 ans=1 ans 1 ct=0 ct 0 for i in range(S+1):
  if int(L[i])==1:
   ans+=((powmod(3, S-i,10**9+7)+1)*powmod(2, ct,10**9+7))%(10**9+7)
   ans%=(10**9+7)
   ct+=1
  i range(S+1) range S+1 S 1 if int(L[i])==1:
   ans+=((powmod(3, S-i,10**9+7)+1)*powmod(2, ct,10**9+7))%(10**9+7)
   ans%=(10**9+7)
   ct+=1
  int(L[i])==1 int(L[i]) int L[i] L i 1 ans+=((powmod(3, S-i,10**9+7)+1)*powmod(2, ct,10**9+7))%(10**9+7) ans ((powmod(3, S-i,10**9+7)+1)*powmod(2, ct,10**9+7))%(10**9+7) (powmod(3, S-i,10**9+7)+1)*powmod(2, ct,10**9+7) powmod(3, S-i,10**9+7)+1 powmod(3, S-i,10**9+7) powmod 3 S-i S i 10**9+7 10**9 10 9 7 1 powmod(2, ct,10**9+7) powmod 2 ct 10**9+7 10**9 10 9 7 10**9+7 10**9 10 9 7 ans%=(10**9+7) ans 10**9+7 10**9 10 9 7 ct+=1 ct 1 print(ans) print ans ans%=(10**9+7) 10**9+7 ans L=input() input() L ans=1 1 ans def powmod(x, n,mod):
  if n == 0:
   return 1
  K = 1
  while n > 1:
   if n % 2 != 0:
    K = K * x%mod
    x = x ** 2%mod
    n = (n - 1) // 2
   else:
    x = x ** 2%mod
    n = n // 2%mod

  return K * x # 指数を割り続け n が 1 に至ったら終了 def powmod(x, n,mod):
  if n == 0:
   return 1
  K = 1
  while n > 1:
   if n % 2 != 0:
    K = K * x%mod
    x = x ** 2%mod
    n = (n - 1) // 2
   else:
    x = x ** 2%mod
    n = n // 2%mod

  return K * x # 指数を割り続け n が 1 に至ったら終了 powmod ans+=((powmod(3, S-i,10**9+7)+1)*powmod(2, ct,10**9+7))%(10**9+7) ((powmod(3, S-i,10**9+7)+1)*powmod(2, ct,10**9+7))%(10**9+7) ans ct+=1 1 ct S=len(L)-1 len(L)-1 S ct=0 0 ct
def powmod(x, n,mod):
  if n == 0:
   return 1
  K = 1
  while n > 1:
   if n % 2 != 0:
    K = K * x%mod
    x = x ** 2%mod
    n = (n - 1) // 2
   else:
    x = x ** 2%mod
    n = n // 2%mod

  return K * x # 指数を割り続け n が 1 に至ったら終了
L=input()
S=len(L)-1
if S==0:
 print(3)
else:
 ans=1
 ct=0
 for i in range(S+1):
  if int(L[i])==1:
   ans+=((powmod(3, S-i,10**9+7)+1)*powmod(2, ct,10**9+7))%(10**9+7)
   ans%=(10**9+7)
   ct+=1
 print(ans)
