import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

L = input()
n = len(L)

cnt_1 = list(accumulate(map(int, list(L))))

ans = pow(2, cnt_1[-1], mod)
for i in range(n):
	if L[i] == "1":
		ans += pow(2, cnt_1[i]-1, mod) * pow(3, n-i-1, mod) % mod
		ans %= mod

print(ans)
 import sys, re sys re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left, insort, insort_left from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() input def INT(): return int(input()) INT def MAP(): return map(int, input().split()) MAP def LIST(): return list(map(int, input().split())) LIST MAP() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) MAP() MAP def ZIP(n): return zip(*(MAP() for _ in range(n))) ZIP n n sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = float('inf') INF float('inf') float 'inf' mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 from decimal import * L = input() L input() input n = len(L) n len(L) len L cnt_1 = list(accumulate(map(int, list(L)))) cnt_1 list(accumulate(map(int, list(L)))) list accumulate(map(int, list(L))) accumulate map(int, list(L)) map int list(L) list L ans = pow(2, cnt_1[-1], mod) ans pow(2, cnt_1[-1], mod) pow 2 cnt_1[-1] cnt_1 -1 mod for i in range(n):
	if L[i] == "1":
		ans += pow(2, cnt_1[i]-1, mod) * pow(3, n-i-1, mod) % mod
		ans %= mod i range(n) range n if L[i] == "1":
		ans += pow(2, cnt_1[i]-1, mod) * pow(3, n-i-1, mod) % mod
		ans %= mod L[i] == "1" L[i] L i "1" ans += pow(2, cnt_1[i]-1, mod) * pow(3, n-i-1, mod) % mod ans pow(2, cnt_1[i]-1, mod) * pow(3, n-i-1, mod) % mod pow(2, cnt_1[i]-1, mod) * pow(3, n-i-1, mod) pow(2, cnt_1[i]-1, mod) pow 2 cnt_1[i]-1 cnt_1[i] cnt_1 i 1 mod pow(3, n-i-1, mod) pow 3 n-i-1 n-i n i 1 mod mod ans %= mod ans mod print(ans) print ans def ZIP(n): return zip(*(MAP() for _ in range(n))) def ZIP(n): return zip(*(MAP() for _ in range(n))) ZIP n = len(L) len(L) n ans = pow(2, cnt_1[-1], mod) pow(2, cnt_1[-1], mod) ans def INT(): return int(input()) def INT(): return int(input()) INT cnt_1 = list(accumulate(map(int, list(L)))) list(accumulate(map(int, list(L)))) cnt_1 ans += pow(2, cnt_1[i]-1, mod) * pow(3, n-i-1, mod) % mod pow(2, cnt_1[i]-1, mod) * pow(3, n-i-1, mod) % mod ans ans %= mod mod ans def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input def LIST(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) LIST INF = float('inf') float('inf') INF mod = 10 ** 9 + 7 10 ** 9 + 7 mod L = input() input() L def MAP(): return map(int, input().split()) def MAP(): return map(int, input().split()) MAP
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

L = input()
n = len(L)

cnt_1 = list(accumulate(map(int, list(L))))

ans = pow(2, cnt_1[-1], mod)
for i in range(n):
	if L[i] == "1":
		ans += pow(2, cnt_1[i]-1, mod) * pow(3, n-i-1, mod) % mod
		ans %= mod

print(ans)

