import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
L = input()

dp = [[0] * 2 for _ in range(len(L) + 1)]

dp[0][0] = 2
dp[0][1] = 1
for i in range(1, len(L)):
    if L[i] == '1':
        dp[i][0] = 2 * dp[i - 1][0] % MOD
        dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % MOD
    else:
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = (3 * dp[i - 1][1]) % MOD
print(sum(dp[len(L) - 1]) % MOD)
# print(dp)
 import sys sys import itertools itertools import time time import math math from heapq import heappop, heappush from collections import defaultdict from collections import Counter from collections import deque from itertools import permutations sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 INF = 10 ** 18 INF 10 ** 18 10 18 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines L = input() L input() input [0] * 2 for _ in range(len(L) + 1) for _ in range(len(L) + 1) _ range(len(L) + 1) range len(L) + 1 len(L) len L 1 for _ in range(len(L) + 1) [0] * 2 [0] 0 2 dp = [[0] * 2 for _ in range(len(L) + 1)] dp [[0] * 2 for _ in range(len(L) + 1)] dp[0][0] = 2 dp[0][0] [0] dp 0 0 2 dp[0][1] = 1 dp[0][1] [0] dp 0 1 1 for i in range(1, len(L)):
    if L[i] == '1':
        dp[i][0] = 2 * dp[i - 1][0] % MOD
        dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % MOD
    else:
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = (3 * dp[i - 1][1]) % MOD i range(1, len(L)) range 1 len(L) len L if L[i] == '1':
        dp[i][0] = 2 * dp[i - 1][0] % MOD
        dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % MOD
    else:
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = (3 * dp[i - 1][1]) % MOD L[i] == '1' L[i] L i '1' dp[i][0] = 2 * dp[i - 1][0] % MOD dp[i][0] [i] dp i 0 2 * dp[i - 1][0] % MOD 2 * dp[i - 1][0] 2 dp[i - 1][0] [i - 1] dp i - 1 i 1 0 MOD dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % MOD dp[i][1] [i] dp i 1 (dp[i - 1][1] * 3 + dp[i - 1][0]) % MOD dp[i - 1][1] * 3 + dp[i - 1][0] dp[i - 1][1] * 3 dp[i - 1][1] [i - 1] dp i - 1 i 1 1 3 dp[i - 1][0] [i - 1] dp i - 1 i 1 0 MOD dp[i][0] = dp[i - 1][0] dp[i][0] [i] dp i 0 dp[i - 1][0] [i - 1] dp i - 1 i 1 0 dp[i][1] = (3 * dp[i - 1][1]) % MOD dp[i][1] [i] dp i 1 (3 * dp[i - 1][1]) % MOD 3 * dp[i - 1][1] 3 dp[i - 1][1] [i - 1] dp i - 1 i 1 1 MOD print(sum(dp[len(L) - 1]) % MOD) print sum(dp[len(L) - 1]) % MOD sum(dp[len(L) - 1]) sum dp[len(L) - 1] dp len(L) - 1 len(L) len L 1 MOD dp = [[0] * 2 for _ in range(len(L) + 1)] [[0] * 2 for _ in range(len(L) + 1)] dp MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines L = input() input() L read = sys.stdin.buffer.read sys.stdin.buffer.read read INF = 10 ** 18 10 ** 18 INF
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
L = input()

dp = [[0] * 2 for _ in range(len(L) + 1)]

dp[0][0] = 2
dp[0][1] = 1
for i in range(1, len(L)):
    if L[i] == '1':
        dp[i][0] = 2 * dp[i - 1][0] % MOD
        dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % MOD
    else:
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = (3 * dp[i - 1][1]) % MOD
print(sum(dp[len(L) - 1]) % MOD)
# print(dp)

