#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass

MOD = 1000000007  # type: int


def solve(L: str):
    a = 1
    b = 1
    for Li in L:
        if Li == "1":
            a *= 3
            a %= MOD
            b *= 2
            b %= MOD
        else:
            a += (a - b) * 2
            a %= MOD
    print(a)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = next(tokens)  # type: str
    solve(L)


if __name__ == '__main__':
    main() import sys sys try:
    from typing import List
except ImportError:
    pass except ImportError:
    pass from typing import List MOD = 1000000007 MOD 1000000007 def solve(L: str):
    a = 1
    b = 1
    for Li in L:
        if Li == "1":
            a *= 3
            a %= MOD
            b *= 2
            b %= MOD
        else:
            a += (a - b) * 2
            a %= MOD
    print(a) solve a = 1 a 1 b = 1 b 1 for Li in L:
        if Li == "1":
            a *= 3
            a %= MOD
            b *= 2
            b %= MOD
        else:
            a += (a - b) * 2
            a %= MOD
     Li L if Li == "1":
            a *= 3
            a %= MOD
            b *= 2
            b %= MOD
        else:
            a += (a - b) * 2
            a %= MOD
     Li == "1" Li "1" a *= 3 a 3 a %= MOD a MOD b *= 2 b 2 b %= MOD b MOD a += (a - b) * 2 a (a - b) * 2 a - b a b 2 a %= MOD a MOD print(a) print a L: str L def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = next(tokens)  # type: str
    solve(L) main def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
     iterate_tokens for line in sys.stdin:
            for word in line.split():
                yield word
     line sys.stdin sys stdin for word in line.split():
                yield word
     word line.split() line.split line split yield word word tokens = iterate_tokens() tokens iterate_tokens() iterate_tokens L = next(tokens) L next(tokens) next tokens solve(L) solve L if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def solve(L: str):
    a = 1
    b = 1
    for Li in L:
        if Li == "1":
            a *= 3
            a %= MOD
            b *= 2
            b %= MOD
        else:
            a += (a - b) * 2
            a %= MOD
    print(a) def solve(L: str):
    a = 1
    b = 1
    for Li in L:
        if Li == "1":
            a *= 3
            a %= MOD
            b *= 2
            b %= MOD
        else:
            a += (a - b) * 2
            a %= MOD
    print(a) solve def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = next(tokens)  # type: str
    solve(L) def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = next(tokens)  # type: str
    solve(L) main MOD = 1000000007 1000000007 MOD
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass

MOD = 1000000007  # type: int


def solve(L: str):
    a = 1
    b = 1
    for Li in L:
        if Li == "1":
            a *= 3
            a %= MOD
            b *= 2
            b %= MOD
        else:
            a += (a - b) * 2
            a %= MOD
    print(a)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = next(tokens)  # type: str
    solve(L)


if __name__ == '__main__':
    main()
