MOD=10**9+7
L=input()

def powmod(a,p):
  if p==0:
    return 1
  elif p==1:
    return a
  else:
    pow2=powmod(a,p//2)
    if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD

sum=0
cnt_2=1
for i in range(len(L)):  
  if L[i] == "1":
    sum += cnt_2*powmod(3,len(L)-i-1)
    sum %= MOD
    cnt_2 = (cnt_2*2)%MOD
    
sum += cnt_2
sum %= MOD
print(sum) MOD=10**9+7 MOD 10**9+7 10**9 10 9 7 L=input() L input() input def powmod(a,p):
  if p==0:
    return 1
  elif p==1:
    return a
  else:
    pow2=powmod(a,p//2)
    if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD powmod if p==0:
    return 1
  elif p==1:
    return a
  else:
    pow2=powmod(a,p//2)
    if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD p==0 p 0 return 1 1 elif p==1:
    return a
   p==1 p 1 return a a pow2=powmod(a,p//2) pow2 powmod(a,p//2) powmod a p//2 p 2 if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD p%2==0 p%2 p 2 0 return (pow2**2)%MOD (pow2**2)%MOD pow2**2 pow2 2 MOD return (a*pow2**2)%MOD (a*pow2**2)%MOD a*pow2**2 a pow2**2 pow2 2 MOD a a p p sum=0 sum 0 cnt_2=1 cnt_2 1 for i in range(len(L)):  
  if L[i] == "1":
    sum += cnt_2*powmod(3,len(L)-i-1)
    sum %= MOD
    cnt_2 = (cnt_2*2)%MOD
     i range(len(L)) range len(L) len L if L[i] == "1":
    sum += cnt_2*powmod(3,len(L)-i-1)
    sum %= MOD
    cnt_2 = (cnt_2*2)%MOD
     L[i] == "1" L[i] L i "1" sum += cnt_2*powmod(3,len(L)-i-1) sum cnt_2*powmod(3,len(L)-i-1) cnt_2 powmod(3,len(L)-i-1) powmod 3 len(L)-i-1 len(L)-i len(L) len L i 1 sum %= MOD sum MOD cnt_2 = (cnt_2*2)%MOD cnt_2 (cnt_2*2)%MOD cnt_2*2 cnt_2 2 MOD sum += cnt_2 sum cnt_2 sum %= MOD sum MOD print(sum) print sum cnt_2 = (cnt_2*2)%MOD (cnt_2*2)%MOD cnt_2 sum += cnt_2 cnt_2 sum sum %= MOD MOD sum sum %= MOD MOD sum sum=0 0 sum MOD=10**9+7 10**9+7 MOD def powmod(a,p):
  if p==0:
    return 1
  elif p==1:
    return a
  else:
    pow2=powmod(a,p//2)
    if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD def powmod(a,p):
  if p==0:
    return 1
  elif p==1:
    return a
  else:
    pow2=powmod(a,p//2)
    if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD powmod cnt_2=1 1 cnt_2 sum += cnt_2*powmod(3,len(L)-i-1) cnt_2*powmod(3,len(L)-i-1) sum L=input() input() L
MOD=10**9+7
L=input()

def powmod(a,p):
  if p==0:
    return 1
  elif p==1:
    return a
  else:
    pow2=powmod(a,p//2)
    if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD

sum=0
cnt_2=1
for i in range(len(L)):  
  if L[i] == "1":
    sum += cnt_2*powmod(3,len(L)-i-1)
    sum %= MOD
    cnt_2 = (cnt_2*2)%MOD
    
sum += cnt_2
sum %= MOD
print(sum)