def getlist():
	return list(map(int, input().split()))

con = 10 ** 9 + 7

#処理内容
def main():
	L = list(input())
	L = L[::-1]
	N = len(L)
	#前処理
	DP1 = [0] * (N + 1)
	DP2 = [0] * (N + 1)
	DP2[0] = 3
	for i in range(1, N + 1):
		DP2[i] = (3 * DP2[i - 1]) % con
	if L[0] == "1":
		DP1[0] = 3
	else:
		DP1[0] = 1

	#DP
	for i in range(1, N):
		if L[i] == "1":
			DP1[i] = (DP1[i - 1] * 2 + DP2[i - 1]) % con
		else:
			DP1[i] = DP1[i - 1]
	print(DP1[N - 1])


if __name__ == '__main__':
	main() def getlist():
	return list(map(int, input().split())) getlist return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split con = 10 ** 9 + 7 con 10 ** 9 + 7 10 ** 9 10 9 7 def main():
	L = list(input())
	L = L[::-1]
	N = len(L)
	#前処理
	DP1 = [0] * (N + 1)
	DP2 = [0] * (N + 1)
	DP2[0] = 3
	for i in range(1, N + 1):
		DP2[i] = (3 * DP2[i - 1]) % con
	if L[0] == "1":
		DP1[0] = 3
	else:
		DP1[0] = 1

	#DP
	for i in range(1, N):
		if L[i] == "1":
			DP1[i] = (DP1[i - 1] * 2 + DP2[i - 1]) % con
		else:
			DP1[i] = DP1[i - 1]
	print(DP1[N - 1]) main L = list(input()) L list(input()) list input() input L = L[::-1] L L[::-1] L ::-1 -1 N = len(L) N len(L) len L DP1 = [0] * (N + 1) DP1 [0] * (N + 1) [0] 0 N + 1 N 1 DP2 = [0] * (N + 1) DP2 [0] * (N + 1) [0] 0 N + 1 N 1 DP2[0] = 3 DP2[0] DP2 0 3 for i in range(1, N + 1):
		DP2[i] = (3 * DP2[i - 1]) % con
	 i range(1, N + 1) range 1 N + 1 N 1 DP2[i] = (3 * DP2[i - 1]) % con DP2[i] DP2 i (3 * DP2[i - 1]) % con 3 * DP2[i - 1] 3 DP2[i - 1] DP2 i - 1 i 1 con if L[0] == "1":
		DP1[0] = 3
	else:
		DP1[0] = 1

	#DP
	 L[0] == "1" L[0] L 0 "1" DP1[0] = 3 DP1[0] DP1 0 3 DP1[0] = 1 DP1[0] DP1 0 1 for i in range(1, N):
		if L[i] == "1":
			DP1[i] = (DP1[i - 1] * 2 + DP2[i - 1]) % con
		else:
			DP1[i] = DP1[i - 1]
	 i range(1, N) range 1 N if L[i] == "1":
			DP1[i] = (DP1[i - 1] * 2 + DP2[i - 1]) % con
		else:
			DP1[i] = DP1[i - 1]
	 L[i] == "1" L[i] L i "1" DP1[i] = (DP1[i - 1] * 2 + DP2[i - 1]) % con DP1[i] DP1 i (DP1[i - 1] * 2 + DP2[i - 1]) % con DP1[i - 1] * 2 + DP2[i - 1] DP1[i - 1] * 2 DP1[i - 1] DP1 i - 1 i 1 2 DP2[i - 1] DP2 i - 1 i 1 con DP1[i] = DP1[i - 1] DP1[i] DP1 i DP1[i - 1] DP1 i - 1 i 1 print(DP1[N - 1]) print DP1[N - 1] DP1 N - 1 N 1 if __name__ == '__main__':
	main() __name__ == '__main__' __name__ '__main__' main() main def getlist():
	return list(map(int, input().split())) def getlist():
	return list(map(int, input().split())) getlist con = 10 ** 9 + 7 10 ** 9 + 7 con def main():
	L = list(input())
	L = L[::-1]
	N = len(L)
	#前処理
	DP1 = [0] * (N + 1)
	DP2 = [0] * (N + 1)
	DP2[0] = 3
	for i in range(1, N + 1):
		DP2[i] = (3 * DP2[i - 1]) % con
	if L[0] == "1":
		DP1[0] = 3
	else:
		DP1[0] = 1

	#DP
	for i in range(1, N):
		if L[i] == "1":
			DP1[i] = (DP1[i - 1] * 2 + DP2[i - 1]) % con
		else:
			DP1[i] = DP1[i - 1]
	print(DP1[N - 1]) def main():
	L = list(input())
	L = L[::-1]
	N = len(L)
	#前処理
	DP1 = [0] * (N + 1)
	DP2 = [0] * (N + 1)
	DP2[0] = 3
	for i in range(1, N + 1):
		DP2[i] = (3 * DP2[i - 1]) % con
	if L[0] == "1":
		DP1[0] = 3
	else:
		DP1[0] = 1

	#DP
	for i in range(1, N):
		if L[i] == "1":
			DP1[i] = (DP1[i - 1] * 2 + DP2[i - 1]) % con
		else:
			DP1[i] = DP1[i - 1]
	print(DP1[N - 1]) main
def getlist():
	return list(map(int, input().split()))

con = 10 ** 9 + 7

#処理内容
def main():
	L = list(input())
	L = L[::-1]
	N = len(L)
	#前処理
	DP1 = [0] * (N + 1)
	DP2 = [0] * (N + 1)
	DP2[0] = 3
	for i in range(1, N + 1):
		DP2[i] = (3 * DP2[i - 1]) % con
	if L[0] == "1":
		DP1[0] = 3
	else:
		DP1[0] = 1

	#DP
	for i in range(1, N):
		if L[i] == "1":
			DP1[i] = (DP1[i - 1] * 2 + DP2[i - 1]) % con
		else:
			DP1[i] = DP1[i - 1]
	print(DP1[N - 1])


if __name__ == '__main__':
	main()