import sys
from functools import lru_cache

sys.setrecursionlimit(1000000000)

MOD = 10 ** 9 + 7

@lru_cache(maxsize=None)
def r(k, smaller):
    global s

    if k == len(s):
        return 1

    if smaller:
        if s[k] == "1":
            return (2 * r(k + 1, True) + r(k + 1, False)) % MOD
        else:
            return r(k + 1, True) % MOD
    else:
        return (3 * r(k + 1, False)) % MOD


s = input()
print(r(0, True)) import sys sys from functools import lru_cache sys.setrecursionlimit(1000000000) sys.setrecursionlimit sys setrecursionlimit 1000000000 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 def r(k, smaller):
    global s

    if k == len(s):
        return 1

    if smaller:
        if s[k] == "1":
            return (2 * r(k + 1, True) + r(k + 1, False)) % MOD
        else:
            return r(k + 1, True) % MOD
    else:
        return (3 * r(k + 1, False)) % MOD r global s if k == len(s):
        return 1

     k == len(s) k len(s) len s return 1 1 if smaller:
        if s[k] == "1":
            return (2 * r(k + 1, True) + r(k + 1, False)) % MOD
        else:
            return r(k + 1, True) % MOD
    else:
        return (3 * r(k + 1, False)) % MOD smaller if s[k] == "1":
            return (2 * r(k + 1, True) + r(k + 1, False)) % MOD
        else:
            return r(k + 1, True) % MOD
     s[k] == "1" s[k] s k "1" return (2 * r(k + 1, True) + r(k + 1, False)) % MOD (2 * r(k + 1, True) + r(k + 1, False)) % MOD 2 * r(k + 1, True) + r(k + 1, False) 2 * r(k + 1, True) 2 r(k + 1, True) r k + 1 k 1 True r(k + 1, False) r k + 1 k 1 False MOD return r(k + 1, True) % MOD r(k + 1, True) % MOD r(k + 1, True) r k + 1 k 1 True MOD return (3 * r(k + 1, False)) % MOD (3 * r(k + 1, False)) % MOD 3 * r(k + 1, False) 3 r(k + 1, False) r k + 1 k 1 False MOD k k smaller smaller @lru_cache(maxsize=None) r maxsize=None @lru_cache(maxsize=None) lru_cache maxsize=None maxsize None r s = input() s input() input print(r(0, True)) print r(0, True) r 0 True MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD def r(k, smaller):
    global s

    if k == len(s):
        return 1

    if smaller:
        if s[k] == "1":
            return (2 * r(k + 1, True) + r(k + 1, False)) % MOD
        else:
            return r(k + 1, True) % MOD
    else:
        return (3 * r(k + 1, False)) % MOD def r(k, smaller):
    global s

    if k == len(s):
        return 1

    if smaller:
        if s[k] == "1":
            return (2 * r(k + 1, True) + r(k + 1, False)) % MOD
        else:
            return r(k + 1, True) % MOD
    else:
        return (3 * r(k + 1, False)) % MOD r s = input() input() s
import sys
from functools import lru_cache

sys.setrecursionlimit(1000000000)

MOD = 10 ** 9 + 7

@lru_cache(maxsize=None)
def r(k, smaller):
    global s

    if k == len(s):
        return 1

    if smaller:
        if s[k] == "1":
            return (2 * r(k + 1, True) + r(k + 1, False)) % MOD
        else:
            return r(k + 1, True) % MOD
    else:
        return (3 * r(k + 1, False)) % MOD


s = input()
print(r(0, True))
