# -*- coding: utf-8 -*-
# import bisect
# import heapq
# import math
# import random
# from collections import Counter, defaultdict, deque
# from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
# from fractions import Fraction
# from functools import lru_cache, reduce
# from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
# from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(L):
    M = 10**9 + 7
    ans = 1
    m = 0
    for b in map(int, L):
        m *= 3
        if b == 1:
            m += ans
            ans *= 2

        ans %= M
        m %= M
    ans += m
    ans %= M
    return ans


def main():
    L = read_str()
    print(slv(L))


if __name__ == '__main__':
    main() import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline INF = 2**62-1 INF 2**62-1 2**62 2 62 1 def read_int():
    return int(readline()) read_int return int(readline()) int(readline()) int readline() readline def read_int_n():
    return list(map(int, readline().split())) read_int_n return list(map(int, readline().split())) list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline split def read_float():
    return float(readline()) read_float return float(readline()) float(readline()) float readline() readline def read_float_n():
    return list(map(float, readline().split())) read_float_n return list(map(float, readline().split())) list(map(float, readline().split())) list map(float, readline().split()) map float readline().split() ().split () readline split def read_str():
    return readline().strip() read_str return readline().strip() readline().strip() ().strip () readline strip def read_str_n():
    return readline().strip().split() read_str_n return readline().strip().split() readline().strip().split() ().strip().split ().strip() ().strip () readline strip split def error_print(*args):
    print(*args, file=sys.stderr) error_print print(*args, file=sys.stderr) print *args args file=sys.stderr file sys.stderr sys stderr *args def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        error_print(e - s, 'sec')
        return ret

    return wrap mt import time time def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        error_print(e - s, 'sec')
        return ret

     wrap s = time.perf_counter() s time.perf_counter() time.perf_counter time perf_counter ret = f(*args, **kwargs) ret f(*args, **kwargs) f *args args **kwargs kwargs e = time.perf_counter() e time.perf_counter() time.perf_counter time perf_counter error_print(e - s, 'sec') error_print e - s e s 'sec' return ret ret *args **kwargs return wrap wrap f f def slv(L):
    M = 10**9 + 7
    ans = 1
    m = 0
    for b in map(int, L):
        m *= 3
        if b == 1:
            m += ans
            ans *= 2

        ans %= M
        m %= M
    ans += m
    ans %= M
    return ans slv M = 10**9 + 7 M 10**9 + 7 10**9 10 9 7 ans = 1 ans 1 m = 0 m 0 for b in map(int, L):
        m *= 3
        if b == 1:
            m += ans
            ans *= 2

        ans %= M
        m %= M
     b map(int, L) map int L m *= 3 m 3 if b == 1:
            m += ans
            ans *= 2

         b == 1 b 1 m += ans m ans ans *= 2 ans 2 ans %= M ans M m %= M m M ans += m ans m ans %= M ans M return ans ans L L @mt slv mt slv def main():
    L = read_str()
    print(slv(L)) main L = read_str() L read_str() read_str print(slv(L)) print slv(L) slv L if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def read_int_n():
    return list(map(int, readline().split())) def read_int_n():
    return list(map(int, readline().split())) read_int_n def read_int():
    return int(readline()) def read_int():
    return int(readline()) read_int def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        error_print(e - s, 'sec')
        return ret

    return wrap def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        error_print(e - s, 'sec')
        return ret

    return wrap mt def read_float():
    return float(readline()) def read_float():
    return float(readline()) read_float def error_print(*args):
    print(*args, file=sys.stderr) def error_print(*args):
    print(*args, file=sys.stderr) error_print def read_str_n():
    return readline().strip().split() def read_str_n():
    return readline().strip().split() read_str_n def read_str():
    return readline().strip() def read_str():
    return readline().strip() read_str readline = sys.stdin.readline sys.stdin.readline readline INF = 2**62-1 2**62-1 INF def main():
    L = read_str()
    print(slv(L)) def main():
    L = read_str()
    print(slv(L)) main def read_float_n():
    return list(map(float, readline().split())) def read_float_n():
    return list(map(float, readline().split())) read_float_n def slv(L):
    M = 10**9 + 7
    ans = 1
    m = 0
    for b in map(int, L):
        m *= 3
        if b == 1:
            m += ans
            ans *= 2

        ans %= M
        m %= M
    ans += m
    ans %= M
    return ans def slv(L):
    M = 10**9 + 7
    ans = 1
    m = 0
    for b in map(int, L):
        m *= 3
        if b == 1:
            m += ans
            ans *= 2

        ans %= M
        m %= M
    ans += m
    ans %= M
    return ans slv
# -*- coding: utf-8 -*-
# import bisect
# import heapq
# import math
# import random
# from collections import Counter, defaultdict, deque
# from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
# from fractions import Fraction
# from functools import lru_cache, reduce
# from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
# from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(L):
    M = 10**9 + 7
    ans = 1
    m = 0
    for b in map(int, L):
        m *= 3
        if b == 1:
            m += ans
            ans *= 2

        ans %= M
        m %= M
    ans += m
    ans %= M
    return ans


def main():
    L = read_str()
    print(slv(L))


if __name__ == '__main__':
    main()
