#!python3

# input
L = input()

MOD = 10 ** 9 + 7
MAX = 10 ** 5 + 5
p3 = [None] * MAX


def p3_init():
    p3[0] = 1
    for i in range(1, MAX):
        p3[i] = 3 * p3[i - 1] % MOD


def main():
    p3_init()
    n = len(L)
    w = 1
    ans = 0
    for i in range(n):
        if L[i] == "1":
            # 両方0にする場合
            ans = (ans + w * p3[n - i - 1]) % MOD
            # 片方1にする場合
            w = 2 * w % MOD
    ans = (ans + w) % MOD
    print(ans)


if __name__ == "__main__":
    main() L = input() L input() input MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 MAX = 10 ** 5 + 5 MAX 10 ** 5 + 5 10 ** 5 10 5 5 p3 = [None] * MAX p3 [None] * MAX [None] None MAX def p3_init():
    p3[0] = 1
    for i in range(1, MAX):
        p3[i] = 3 * p3[i - 1] % MOD p3_init p3[0] = 1 p3[0] p3 0 1 for i in range(1, MAX):
        p3[i] = 3 * p3[i - 1] % MOD i range(1, MAX) range 1 MAX p3[i] = 3 * p3[i - 1] % MOD p3[i] p3 i 3 * p3[i - 1] % MOD 3 * p3[i - 1] 3 p3[i - 1] p3 i - 1 i 1 MOD def main():
    p3_init()
    n = len(L)
    w = 1
    ans = 0
    for i in range(n):
        if L[i] == "1":
            # 両方0にする場合
            ans = (ans + w * p3[n - i - 1]) % MOD
            # 片方1にする場合
            w = 2 * w % MOD
    ans = (ans + w) % MOD
    print(ans) main p3_init() p3_init n = len(L) n len(L) len L w = 1 w 1 ans = 0 ans 0 for i in range(n):
        if L[i] == "1":
            # 両方0にする場合
            ans = (ans + w * p3[n - i - 1]) % MOD
            # 片方1にする場合
            w = 2 * w % MOD
     i range(n) range n if L[i] == "1":
            # 両方0にする場合
            ans = (ans + w * p3[n - i - 1]) % MOD
            # 片方1にする場合
            w = 2 * w % MOD
     L[i] == "1" L[i] L i "1" ans = (ans + w * p3[n - i - 1]) % MOD ans (ans + w * p3[n - i - 1]) % MOD ans + w * p3[n - i - 1] ans w * p3[n - i - 1] w p3[n - i - 1] p3 n - i - 1 n - i n i 1 MOD w = 2 * w % MOD w 2 * w % MOD 2 * w 2 w MOD ans = (ans + w) % MOD ans (ans + w) % MOD ans + w ans w MOD print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main p3 = [None] * MAX [None] * MAX p3 def p3_init():
    p3[0] = 1
    for i in range(1, MAX):
        p3[i] = 3 * p3[i - 1] % MOD def p3_init():
    p3[0] = 1
    for i in range(1, MAX):
        p3[i] = 3 * p3[i - 1] % MOD p3_init L = input() input() L def main():
    p3_init()
    n = len(L)
    w = 1
    ans = 0
    for i in range(n):
        if L[i] == "1":
            # 両方0にする場合
            ans = (ans + w * p3[n - i - 1]) % MOD
            # 片方1にする場合
            w = 2 * w % MOD
    ans = (ans + w) % MOD
    print(ans) def main():
    p3_init()
    n = len(L)
    w = 1
    ans = 0
    for i in range(n):
        if L[i] == "1":
            # 両方0にする場合
            ans = (ans + w * p3[n - i - 1]) % MOD
            # 片方1にする場合
            w = 2 * w % MOD
    ans = (ans + w) % MOD
    print(ans) main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD MAX = 10 ** 5 + 5 10 ** 5 + 5 MAX
#!python3

# input
L = input()

MOD = 10 ** 9 + 7
MAX = 10 ** 5 + 5
p3 = [None] * MAX


def p3_init():
    p3[0] = 1
    for i in range(1, MAX):
        p3[i] = 3 * p3[i - 1] % MOD


def main():
    p3_init()
    n = len(L)
    w = 1
    ans = 0
    for i in range(n):
        if L[i] == "1":
            # 両方0にする場合
            ans = (ans + w * p3[n - i - 1]) % MOD
            # 片方1にする場合
            w = 2 * w % MOD
    ans = (ans + w) % MOD
    print(ans)


if __name__ == "__main__":
    main()
