# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    l = input()
    n = len(l)

    dp_small = [0] * n
    dp_indet = [0] * n

    dp_small[0] = 1
    dp_indet[0] = 2

    for i in range(1,n):
        bit = l[i]

        if bit == "1":
            dp_small[i] += dp_small[i-1] * 3 + dp_indet[i-1]
            dp_indet[i] += 2 * dp_indet[i-1]
        else:
            dp_small[i] += dp_small[i-1] * 3
            dp_indet[i] += dp_indet[i-1]

        dp_small[i] %= MOD
        dp_indet[i] %= MOD

    print((dp_small[-1]+dp_indet[-1])% MOD)


if __name__ == '__main__':
    main() import sys sys ipti = sys.stdin.readline ipti sys.stdin.readline sys.stdin sys stdin readline MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = float('INF') INF float('INF') float 'INF' sys.setrecursionlimit(10 ** 5) sys.setrecursionlimit sys setrecursionlimit 10 ** 5 10 5 def main():
    l = input()
    n = len(l)

    dp_small = [0] * n
    dp_indet = [0] * n

    dp_small[0] = 1
    dp_indet[0] = 2

    for i in range(1,n):
        bit = l[i]

        if bit == "1":
            dp_small[i] += dp_small[i-1] * 3 + dp_indet[i-1]
            dp_indet[i] += 2 * dp_indet[i-1]
        else:
            dp_small[i] += dp_small[i-1] * 3
            dp_indet[i] += dp_indet[i-1]

        dp_small[i] %= MOD
        dp_indet[i] %= MOD

    print((dp_small[-1]+dp_indet[-1])% MOD) main l = input() l input() input n = len(l) n len(l) len l dp_small = [0] * n dp_small [0] * n [0] 0 n dp_indet = [0] * n dp_indet [0] * n [0] 0 n dp_small[0] = 1 dp_small[0] dp_small 0 1 dp_indet[0] = 2 dp_indet[0] dp_indet 0 2 for i in range(1,n):
        bit = l[i]

        if bit == "1":
            dp_small[i] += dp_small[i-1] * 3 + dp_indet[i-1]
            dp_indet[i] += 2 * dp_indet[i-1]
        else:
            dp_small[i] += dp_small[i-1] * 3
            dp_indet[i] += dp_indet[i-1]

        dp_small[i] %= MOD
        dp_indet[i] %= MOD

     i range(1,n) range 1 n bit = l[i] bit l[i] l i if bit == "1":
            dp_small[i] += dp_small[i-1] * 3 + dp_indet[i-1]
            dp_indet[i] += 2 * dp_indet[i-1]
        else:
            dp_small[i] += dp_small[i-1] * 3
            dp_indet[i] += dp_indet[i-1]

         bit == "1" bit "1" dp_small[i] += dp_small[i-1] * 3 + dp_indet[i-1] dp_small[i] dp_small i dp_small[i-1] * 3 + dp_indet[i-1] dp_small[i-1] * 3 dp_small[i-1] dp_small i-1 i 1 3 dp_indet[i-1] dp_indet i-1 i 1 dp_indet[i] += 2 * dp_indet[i-1] dp_indet[i] dp_indet i 2 * dp_indet[i-1] 2 dp_indet[i-1] dp_indet i-1 i 1 dp_small[i] += dp_small[i-1] * 3 dp_small[i] dp_small i dp_small[i-1] * 3 dp_small[i-1] dp_small i-1 i 1 3 dp_indet[i] += dp_indet[i-1] dp_indet[i] dp_indet i dp_indet[i-1] dp_indet i-1 i 1 dp_small[i] %= MOD dp_small[i] dp_small i MOD dp_indet[i] %= MOD dp_indet[i] dp_indet i MOD print((dp_small[-1]+dp_indet[-1])% MOD) print (dp_small[-1]+dp_indet[-1])% MOD dp_small[-1]+dp_indet[-1] dp_small[-1] dp_small -1 dp_indet[-1] dp_indet -1 MOD if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    l = input()
    n = len(l)

    dp_small = [0] * n
    dp_indet = [0] * n

    dp_small[0] = 1
    dp_indet[0] = 2

    for i in range(1,n):
        bit = l[i]

        if bit == "1":
            dp_small[i] += dp_small[i-1] * 3 + dp_indet[i-1]
            dp_indet[i] += 2 * dp_indet[i-1]
        else:
            dp_small[i] += dp_small[i-1] * 3
            dp_indet[i] += dp_indet[i-1]

        dp_small[i] %= MOD
        dp_indet[i] %= MOD

    print((dp_small[-1]+dp_indet[-1])% MOD) def main():
    l = input()
    n = len(l)

    dp_small = [0] * n
    dp_indet = [0] * n

    dp_small[0] = 1
    dp_indet[0] = 2

    for i in range(1,n):
        bit = l[i]

        if bit == "1":
            dp_small[i] += dp_small[i-1] * 3 + dp_indet[i-1]
            dp_indet[i] += 2 * dp_indet[i-1]
        else:
            dp_small[i] += dp_small[i-1] * 3
            dp_indet[i] += dp_indet[i-1]

        dp_small[i] %= MOD
        dp_indet[i] %= MOD

    print((dp_small[-1]+dp_indet[-1])% MOD) main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD ipti = sys.stdin.readline sys.stdin.readline ipti INF = float('INF') float('INF') INF
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    l = input()
    n = len(l)

    dp_small = [0] * n
    dp_indet = [0] * n

    dp_small[0] = 1
    dp_indet[0] = 2

    for i in range(1,n):
        bit = l[i]

        if bit == "1":
            dp_small[i] += dp_small[i-1] * 3 + dp_indet[i-1]
            dp_indet[i] += 2 * dp_indet[i-1]
        else:
            dp_small[i] += dp_small[i-1] * 3
            dp_indet[i] += dp_indet[i-1]

        dp_small[i] %= MOD
        dp_indet[i] %= MOD

    print((dp_small[-1]+dp_indet[-1])% MOD)


if __name__ == '__main__':
    main()
