import sys
from collections import deque
from functools import lru_cache
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]

def main():
    L = input().strip()
    N = len(L)
    dp = [[0] * (N + 1) for _ in range(2)]
    dp[0][0] = 1
    for i, a in enumerate(L):
        if a == "0":
            dp[0][i + 1] = dp[0][i]
            dp[1][i + 1] = (3 * dp[1][i]) % mod
        else:
            dp[0][i + 1] = (2 * dp[0][i]) % mod
            dp[1][i + 1] = (dp[0][i] + 3 * dp[1][i]) % mod

    # print(dp) 
    print((dp[0][N] + dp[1][N]) % mod)


if __name__ == "__main__":
    main()
 import sys sys from collections import deque from functools import lru_cache import bisect bisect import copy copy import heapq heapq import itertools itertools import math math input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 def read_values(): return map(int, input().split()) read_values def read_index(): return map(lambda x: int(x) - 1, input().split()) read_index def read_list(): return list(read_values()) read_list read_list() for n in range(N) for n in range(N) n range(N) range N for n in range(N) read_list() read_list def read_lists(N): return [read_list() for n in range(N)] read_lists N N def main():
    L = input().strip()
    N = len(L)
    dp = [[0] * (N + 1) for _ in range(2)]
    dp[0][0] = 1
    for i, a in enumerate(L):
        if a == "0":
            dp[0][i + 1] = dp[0][i]
            dp[1][i + 1] = (3 * dp[1][i]) % mod
        else:
            dp[0][i + 1] = (2 * dp[0][i]) % mod
            dp[1][i + 1] = (dp[0][i] + 3 * dp[1][i]) % mod

    # print(dp) 
    print((dp[0][N] + dp[1][N]) % mod) main L = input().strip() L input().strip() ().strip () input strip N = len(L) N len(L) len L [0] * (N + 1) for _ in range(2) for _ in range(2) _ range(2) range 2 for _ in range(2) [0] * (N + 1) [0] 0 N + 1 N 1 dp = [[0] * (N + 1) for _ in range(2)] dp [[0] * (N + 1) for _ in range(2)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 for i, a in enumerate(L):
        if a == "0":
            dp[0][i + 1] = dp[0][i]
            dp[1][i + 1] = (3 * dp[1][i]) % mod
        else:
            dp[0][i + 1] = (2 * dp[0][i]) % mod
            dp[1][i + 1] = (dp[0][i] + 3 * dp[1][i]) % mod

    # print(dp) 
     i a enumerate(L) enumerate L if a == "0":
            dp[0][i + 1] = dp[0][i]
            dp[1][i + 1] = (3 * dp[1][i]) % mod
        else:
            dp[0][i + 1] = (2 * dp[0][i]) % mod
            dp[1][i + 1] = (dp[0][i] + 3 * dp[1][i]) % mod

    # print(dp) 
     a == "0" a "0" dp[0][i + 1] = dp[0][i] dp[0][i + 1] [0] dp 0 i + 1 i 1 dp[0][i] [0] dp 0 i dp[1][i + 1] = (3 * dp[1][i]) % mod dp[1][i + 1] [1] dp 1 i + 1 i 1 (3 * dp[1][i]) % mod 3 * dp[1][i] 3 dp[1][i] [1] dp 1 i mod dp[0][i + 1] = (2 * dp[0][i]) % mod dp[0][i + 1] [0] dp 0 i + 1 i 1 (2 * dp[0][i]) % mod 2 * dp[0][i] 2 dp[0][i] [0] dp 0 i mod dp[1][i + 1] = (dp[0][i] + 3 * dp[1][i]) % mod dp[1][i + 1] [1] dp 1 i + 1 i 1 (dp[0][i] + 3 * dp[1][i]) % mod dp[0][i] + 3 * dp[1][i] dp[0][i] [0] dp 0 i 3 * dp[1][i] 3 dp[1][i] [1] dp 1 i mod print((dp[0][N] + dp[1][N]) % mod) print (dp[0][N] + dp[1][N]) % mod dp[0][N] + dp[1][N] dp[0][N] [0] dp 0 N dp[1][N] [1] dp 1 N mod if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main input = sys.stdin.readline sys.stdin.readline input def read_lists(N): return [read_list() for n in range(N)] def read_lists(N): return [read_list() for n in range(N)] read_lists def read_index(): return map(lambda x: int(x) - 1, input().split()) def read_index(): return map(lambda x: int(x) - 1, input().split()) read_index def read_values(): return map(int, input().split()) def read_values(): return map(int, input().split()) read_values def read_list(): return list(read_values()) def read_list(): return list(read_values()) read_list def main():
    L = input().strip()
    N = len(L)
    dp = [[0] * (N + 1) for _ in range(2)]
    dp[0][0] = 1
    for i, a in enumerate(L):
        if a == "0":
            dp[0][i + 1] = dp[0][i]
            dp[1][i + 1] = (3 * dp[1][i]) % mod
        else:
            dp[0][i + 1] = (2 * dp[0][i]) % mod
            dp[1][i + 1] = (dp[0][i] + 3 * dp[1][i]) % mod

    # print(dp) 
    print((dp[0][N] + dp[1][N]) % mod) def main():
    L = input().strip()
    N = len(L)
    dp = [[0] * (N + 1) for _ in range(2)]
    dp[0][0] = 1
    for i, a in enumerate(L):
        if a == "0":
            dp[0][i + 1] = dp[0][i]
            dp[1][i + 1] = (3 * dp[1][i]) % mod
        else:
            dp[0][i + 1] = (2 * dp[0][i]) % mod
            dp[1][i + 1] = (dp[0][i] + 3 * dp[1][i]) % mod

    # print(dp) 
    print((dp[0][N] + dp[1][N]) % mod) main mod = 10 ** 9 + 7 10 ** 9 + 7 mod
import sys
from collections import deque
from functools import lru_cache
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]

def main():
    L = input().strip()
    N = len(L)
    dp = [[0] * (N + 1) for _ in range(2)]
    dp[0][0] = 1
    for i, a in enumerate(L):
        if a == "0":
            dp[0][i + 1] = dp[0][i]
            dp[1][i + 1] = (3 * dp[1][i]) % mod
        else:
            dp[0][i + 1] = (2 * dp[0][i]) % mod
            dp[1][i + 1] = (dp[0][i] + 3 * dp[1][i]) % mod

    # print(dp) 
    print((dp[0][N] + dp[1][N]) % mod)


if __name__ == "__main__":
    main()

