def main():
    MOD = 10 ** 9 + 7
    L = input()
    a, b = 0, 1
    for i in L:
        if i == '1':
            a, b = (b + a * 2) % MOD, b * 3 % MOD
        else:
            a, b = (a * 3) % MOD, (b + a * 2) % MOD
    return b

print(main()) def main():
    MOD = 10 ** 9 + 7
    L = input()
    a, b = 0, 1
    for i in L:
        if i == '1':
            a, b = (b + a * 2) % MOD, b * 3 % MOD
        else:
            a, b = (a * 3) % MOD, (b + a * 2) % MOD
    return b main MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 L = input() L input() input a, b = 0, 1 a 0 b 1 for i in L:
        if i == '1':
            a, b = (b + a * 2) % MOD, b * 3 % MOD
        else:
            a, b = (a * 3) % MOD, (b + a * 2) % MOD
     i L if i == '1':
            a, b = (b + a * 2) % MOD, b * 3 % MOD
        else:
            a, b = (a * 3) % MOD, (b + a * 2) % MOD
     i == '1' i '1' a, b = (b + a * 2) % MOD, b * 3 % MOD a (b + a * 2) % MOD b + a * 2 b a * 2 a 2 MOD b b * 3 % MOD b * 3 b 3 MOD a, b = (a * 3) % MOD, (b + a * 2) % MOD a (a * 3) % MOD a * 3 a 3 MOD b (b + a * 2) % MOD b + a * 2 b a * 2 a 2 MOD return b b print(main()) print main() main def main():
    MOD = 10 ** 9 + 7
    L = input()
    a, b = 0, 1
    for i in L:
        if i == '1':
            a, b = (b + a * 2) % MOD, b * 3 % MOD
        else:
            a, b = (a * 3) % MOD, (b + a * 2) % MOD
    return b def main():
    MOD = 10 ** 9 + 7
    L = input()
    a, b = 0, 1
    for i in L:
        if i == '1':
            a, b = (b + a * 2) % MOD, b * 3 % MOD
        else:
            a, b = (a * 3) % MOD, (b + a * 2) % MOD
    return b main
def main():
    MOD = 10 ** 9 + 7
    L = input()
    a, b = 0, 1
    for i in L:
        if i == '1':
            a, b = (b + a * 2) % MOD, b * 3 % MOD
        else:
            a, b = (a * 3) % MOD, (b + a * 2) % MOD
    return b

print(main())
