import sys
#input = sys.stdin.buffer.readline

def main():
    L = str(input())
    MOD = 10**9+7
    dpa = [1]
    dpb = [2]
    N = len(L)
    for i in range(1,N):
        if L[i] == "1":
            dpa.append((dpa[-1]*3+dpb[-1])%MOD)
            dpb.append((dpb[-1]*2)%MOD)
        else:
            dpa.append((dpa[-1]*3)%MOD)
            dpb.append((dpb[-1])%MOD)
            
    print((dpa[-1]+dpb[-1])%MOD)

if __name__ == "__main__":
    main() import sys sys def main():
    L = str(input())
    MOD = 10**9+7
    dpa = [1]
    dpb = [2]
    N = len(L)
    for i in range(1,N):
        if L[i] == "1":
            dpa.append((dpa[-1]*3+dpb[-1])%MOD)
            dpb.append((dpb[-1]*2)%MOD)
        else:
            dpa.append((dpa[-1]*3)%MOD)
            dpb.append((dpb[-1])%MOD)
            
    print((dpa[-1]+dpb[-1])%MOD) main L = str(input()) L str(input()) str input() input MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 dpa = [1] dpa [1] 1 dpb = [2] dpb [2] 2 N = len(L) N len(L) len L for i in range(1,N):
        if L[i] == "1":
            dpa.append((dpa[-1]*3+dpb[-1])%MOD)
            dpb.append((dpb[-1]*2)%MOD)
        else:
            dpa.append((dpa[-1]*3)%MOD)
            dpb.append((dpb[-1])%MOD)
            
     i range(1,N) range 1 N if L[i] == "1":
            dpa.append((dpa[-1]*3+dpb[-1])%MOD)
            dpb.append((dpb[-1]*2)%MOD)
        else:
            dpa.append((dpa[-1]*3)%MOD)
            dpb.append((dpb[-1])%MOD)
            
     L[i] == "1" L[i] L i "1" dpa.append((dpa[-1]*3+dpb[-1])%MOD) dpa.append dpa append (dpa[-1]*3+dpb[-1])%MOD dpa[-1]*3+dpb[-1] dpa[-1]*3 dpa[-1] dpa -1 3 dpb[-1] dpb -1 MOD dpb.append((dpb[-1]*2)%MOD) dpb.append dpb append (dpb[-1]*2)%MOD dpb[-1]*2 dpb[-1] dpb -1 2 MOD dpa.append((dpa[-1]*3)%MOD) dpa.append dpa append (dpa[-1]*3)%MOD dpa[-1]*3 dpa[-1] dpa -1 3 MOD dpb.append((dpb[-1])%MOD) dpb.append dpb append (dpb[-1])%MOD dpb[-1] dpb -1 MOD print((dpa[-1]+dpb[-1])%MOD) print (dpa[-1]+dpb[-1])%MOD dpa[-1]+dpb[-1] dpa[-1] dpa -1 dpb[-1] dpb -1 MOD if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    L = str(input())
    MOD = 10**9+7
    dpa = [1]
    dpb = [2]
    N = len(L)
    for i in range(1,N):
        if L[i] == "1":
            dpa.append((dpa[-1]*3+dpb[-1])%MOD)
            dpb.append((dpb[-1]*2)%MOD)
        else:
            dpa.append((dpa[-1]*3)%MOD)
            dpb.append((dpb[-1])%MOD)
            
    print((dpa[-1]+dpb[-1])%MOD) def main():
    L = str(input())
    MOD = 10**9+7
    dpa = [1]
    dpb = [2]
    N = len(L)
    for i in range(1,N):
        if L[i] == "1":
            dpa.append((dpa[-1]*3+dpb[-1])%MOD)
            dpb.append((dpb[-1]*2)%MOD)
        else:
            dpa.append((dpa[-1]*3)%MOD)
            dpb.append((dpb[-1])%MOD)
            
    print((dpa[-1]+dpb[-1])%MOD) main
import sys
#input = sys.stdin.buffer.readline

def main():
    L = str(input())
    MOD = 10**9+7
    dpa = [1]
    dpb = [2]
    N = len(L)
    for i in range(1,N):
        if L[i] == "1":
            dpa.append((dpa[-1]*3+dpb[-1])%MOD)
            dpb.append((dpb[-1]*2)%MOD)
        else:
            dpa.append((dpa[-1]*3)%MOD)
            dpb.append((dpb[-1])%MOD)
            
    print((dpa[-1]+dpb[-1])%MOD)

if __name__ == "__main__":
    main()