import sys
sys.setrecursionlimit(10**9)

def main():
    L = list(input())
    N = len(L)
    MOD = 10**9+7


    dp = [[[0]*2  for _ in range(3)] for _ in  range(N)]

    dp[0][0][1] = 1
    dp[0][1][1] = 1
    dp[0][2][0] = 1

    for i in range(1,N):
        v = sum([dp[i-1][j][0] for j in range(3)]) % MOD
        dp[i][0][0] += v
        dp[i][1][0] += v
        dp[i][2][0] += v
        for j in range(3):
            u = dp[i-1][j][1] % MOD
            if L[i] == "1":
                dp[i][0][1] += u
                dp[i][1][1] += u
                dp[i][2][0] += u
            else:
                dp[i][2][1] += u

    # print(dp)
    print((sum([dp[N-1][i][0]% MOD for i in range(3)]) + sum([dp[N-1][i][1]% MOD for i in range(3)]))% MOD)



if __name__ == "__main__":
  main() import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 def main():
    L = list(input())
    N = len(L)
    MOD = 10**9+7


    dp = [[[0]*2  for _ in range(3)] for _ in  range(N)]

    dp[0][0][1] = 1
    dp[0][1][1] = 1
    dp[0][2][0] = 1

    for i in range(1,N):
        v = sum([dp[i-1][j][0] for j in range(3)]) % MOD
        dp[i][0][0] += v
        dp[i][1][0] += v
        dp[i][2][0] += v
        for j in range(3):
            u = dp[i-1][j][1] % MOD
            if L[i] == "1":
                dp[i][0][1] += u
                dp[i][1][1] += u
                dp[i][2][0] += u
            else:
                dp[i][2][1] += u

    # print(dp)
    print((sum([dp[N-1][i][0]% MOD for i in range(3)]) + sum([dp[N-1][i][1]% MOD for i in range(3)]))% MOD) main L = list(input()) L list(input()) list input() input N = len(L) N len(L) len L MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 [[0]*2  for _ in range(3)] for _ in  range(N) for _ in  range(N) _ range(N) range N for _ in  range(N) [[0]*2  for _ in range(3)] dp = [[[0]*2  for _ in range(3)] for _ in  range(N)] dp [[[0]*2  for _ in range(3)] for _ in  range(N)] dp[0][0][1] = 1 dp[0][0][1] [0] [0] dp 0 0 1 1 dp[0][1][1] = 1 dp[0][1][1] [1] [0] dp 0 1 1 1 dp[0][2][0] = 1 dp[0][2][0] [2] [0] dp 0 2 0 1 for i in range(1,N):
        v = sum([dp[i-1][j][0] for j in range(3)]) % MOD
        dp[i][0][0] += v
        dp[i][1][0] += v
        dp[i][2][0] += v
        for j in range(3):
            u = dp[i-1][j][1] % MOD
            if L[i] == "1":
                dp[i][0][1] += u
                dp[i][1][1] += u
                dp[i][2][0] += u
            else:
                dp[i][2][1] += u

    # print(dp)
     i range(1,N) range 1 N dp[i-1][j][0] for j in range(3) for j in range(3) j range(3) range 3 for j in range(3) dp[i-1][j][0] [j] [i-1] dp i-1 i 1 j 0 v = sum([dp[i-1][j][0] for j in range(3)]) % MOD v sum([dp[i-1][j][0] for j in range(3)]) % MOD sum([dp[i-1][j][0] for j in range(3)]) sum [dp[i-1][j][0] for j in range(3)] MOD dp[i][0][0] += v dp[i][0][0] [0] [i] dp i 0 0 v dp[i][1][0] += v dp[i][1][0] [1] [i] dp i 1 0 v dp[i][2][0] += v dp[i][2][0] [2] [i] dp i 2 0 v for j in range(3):
            u = dp[i-1][j][1] % MOD
            if L[i] == "1":
                dp[i][0][1] += u
                dp[i][1][1] += u
                dp[i][2][0] += u
            else:
                dp[i][2][1] += u

    # print(dp)
     j range(3) range 3 u = dp[i-1][j][1] % MOD u dp[i-1][j][1] % MOD dp[i-1][j][1] [j] [i-1] dp i-1 i 1 j 1 MOD if L[i] == "1":
                dp[i][0][1] += u
                dp[i][1][1] += u
                dp[i][2][0] += u
            else:
                dp[i][2][1] += u

    # print(dp)
     L[i] == "1" L[i] L i "1" dp[i][0][1] += u dp[i][0][1] [0] [i] dp i 0 1 u dp[i][1][1] += u dp[i][1][1] [1] [i] dp i 1 1 u dp[i][2][0] += u dp[i][2][0] [2] [i] dp i 2 0 u dp[i][2][1] += u dp[i][2][1] [2] [i] dp i 2 1 u dp[N-1][i][0]% MOD for i in range(3) for i in range(3) i range(3) range 3 for i in range(3) dp[N-1][i][0]% MOD dp[N-1][i][0] [i] [N-1] dp N-1 N 1 i 0 MOD print((sum([dp[N-1][i][0]% MOD for i in range(3)]) + sum([dp[N-1][i][1]% MOD for i in range(3)]))% MOD) print (sum([dp[N-1][i][0]% MOD for i in range(3)]) + sum([dp[N-1][i][1]% MOD for i in range(3)]))% MOD sum([dp[N-1][i][0]% MOD for i in range(3)]) + sum([dp[N-1][i][1]% MOD for i in range(3)]) sum([dp[N-1][i][0]% MOD for i in range(3)]) sum [dp[N-1][i][0]% MOD for i in range(3)] sum([dp[N-1][i][1]% MOD for i in range(3)]) sum [dp[N-1][i][1]% MOD for i in range(3)] MOD if __name__ == "__main__":
  main() __name__ == "__main__" __name__ "__main__" main() main def main():
    L = list(input())
    N = len(L)
    MOD = 10**9+7


    dp = [[[0]*2  for _ in range(3)] for _ in  range(N)]

    dp[0][0][1] = 1
    dp[0][1][1] = 1
    dp[0][2][0] = 1

    for i in range(1,N):
        v = sum([dp[i-1][j][0] for j in range(3)]) % MOD
        dp[i][0][0] += v
        dp[i][1][0] += v
        dp[i][2][0] += v
        for j in range(3):
            u = dp[i-1][j][1] % MOD
            if L[i] == "1":
                dp[i][0][1] += u
                dp[i][1][1] += u
                dp[i][2][0] += u
            else:
                dp[i][2][1] += u

    # print(dp)
    print((sum([dp[N-1][i][0]% MOD for i in range(3)]) + sum([dp[N-1][i][1]% MOD for i in range(3)]))% MOD) def main():
    L = list(input())
    N = len(L)
    MOD = 10**9+7


    dp = [[[0]*2  for _ in range(3)] for _ in  range(N)]

    dp[0][0][1] = 1
    dp[0][1][1] = 1
    dp[0][2][0] = 1

    for i in range(1,N):
        v = sum([dp[i-1][j][0] for j in range(3)]) % MOD
        dp[i][0][0] += v
        dp[i][1][0] += v
        dp[i][2][0] += v
        for j in range(3):
            u = dp[i-1][j][1] % MOD
            if L[i] == "1":
                dp[i][0][1] += u
                dp[i][1][1] += u
                dp[i][2][0] += u
            else:
                dp[i][2][1] += u

    # print(dp)
    print((sum([dp[N-1][i][0]% MOD for i in range(3)]) + sum([dp[N-1][i][1]% MOD for i in range(3)]))% MOD) main
import sys
sys.setrecursionlimit(10**9)

def main():
    L = list(input())
    N = len(L)
    MOD = 10**9+7


    dp = [[[0]*2  for _ in range(3)] for _ in  range(N)]

    dp[0][0][1] = 1
    dp[0][1][1] = 1
    dp[0][2][0] = 1

    for i in range(1,N):
        v = sum([dp[i-1][j][0] for j in range(3)]) % MOD
        dp[i][0][0] += v
        dp[i][1][0] += v
        dp[i][2][0] += v
        for j in range(3):
            u = dp[i-1][j][1] % MOD
            if L[i] == "1":
                dp[i][0][1] += u
                dp[i][1][1] += u
                dp[i][2][0] += u
            else:
                dp[i][2][1] += u

    # print(dp)
    print((sum([dp[N-1][i][0]% MOD for i in range(3)]) + sum([dp[N-1][i][1]% MOD for i in range(3)]))% MOD)



if __name__ == "__main__":
  main()
