import sys

MOD = 10 ** 9 + 7

s = sys.stdin.readline().rstrip()
l = len(s)

def main():
    dp1 = [0] * (l + 1)
    dp2 = [0] * (l + 1)
    dp2[0] = 1
    for i in range(l):
        dp1[i+1] = dp1[i] * 3
        if s[i] == '1':
            dp1[i+1] += dp2[i]
            dp2[i+1] = dp2[i] * 2
        else:
            dp2[i+1] = dp2[i]
        dp1[i+1] %= MOD
        dp2[i+1] %= MOD

    return (dp1[l] + dp2[l]) % MOD

if __name__ == '__main__':
    ans = main()
    print(ans) import sys sys MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 s = sys.stdin.readline().rstrip() s sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip l = len(s) l len(s) len s def main():
    dp1 = [0] * (l + 1)
    dp2 = [0] * (l + 1)
    dp2[0] = 1
    for i in range(l):
        dp1[i+1] = dp1[i] * 3
        if s[i] == '1':
            dp1[i+1] += dp2[i]
            dp2[i+1] = dp2[i] * 2
        else:
            dp2[i+1] = dp2[i]
        dp1[i+1] %= MOD
        dp2[i+1] %= MOD

    return (dp1[l] + dp2[l]) % MOD main dp1 = [0] * (l + 1) dp1 [0] * (l + 1) [0] 0 l + 1 l 1 dp2 = [0] * (l + 1) dp2 [0] * (l + 1) [0] 0 l + 1 l 1 dp2[0] = 1 dp2[0] dp2 0 1 for i in range(l):
        dp1[i+1] = dp1[i] * 3
        if s[i] == '1':
            dp1[i+1] += dp2[i]
            dp2[i+1] = dp2[i] * 2
        else:
            dp2[i+1] = dp2[i]
        dp1[i+1] %= MOD
        dp2[i+1] %= MOD

     i range(l) range l dp1[i+1] = dp1[i] * 3 dp1[i+1] dp1 i+1 i 1 dp1[i] * 3 dp1[i] dp1 i 3 if s[i] == '1':
            dp1[i+1] += dp2[i]
            dp2[i+1] = dp2[i] * 2
        else:
            dp2[i+1] = dp2[i]
         s[i] == '1' s[i] s i '1' dp1[i+1] += dp2[i] dp1[i+1] dp1 i+1 i 1 dp2[i] dp2 i dp2[i+1] = dp2[i] * 2 dp2[i+1] dp2 i+1 i 1 dp2[i] * 2 dp2[i] dp2 i 2 dp2[i+1] = dp2[i] dp2[i+1] dp2 i+1 i 1 dp2[i] dp2 i dp1[i+1] %= MOD dp1[i+1] dp1 i+1 i 1 MOD dp2[i+1] %= MOD dp2[i+1] dp2 i+1 i 1 MOD return (dp1[l] + dp2[l]) % MOD (dp1[l] + dp2[l]) % MOD dp1[l] + dp2[l] dp1[l] dp1 l dp2[l] dp2 l MOD if __name__ == '__main__':
    ans = main()
    print(ans) __name__ == '__main__' __name__ '__main__' ans = main() ans main() main print(ans) print ans def main():
    dp1 = [0] * (l + 1)
    dp2 = [0] * (l + 1)
    dp2[0] = 1
    for i in range(l):
        dp1[i+1] = dp1[i] * 3
        if s[i] == '1':
            dp1[i+1] += dp2[i]
            dp2[i+1] = dp2[i] * 2
        else:
            dp2[i+1] = dp2[i]
        dp1[i+1] %= MOD
        dp2[i+1] %= MOD

    return (dp1[l] + dp2[l]) % MOD def main():
    dp1 = [0] * (l + 1)
    dp2 = [0] * (l + 1)
    dp2[0] = 1
    for i in range(l):
        dp1[i+1] = dp1[i] * 3
        if s[i] == '1':
            dp1[i+1] += dp2[i]
            dp2[i+1] = dp2[i] * 2
        else:
            dp2[i+1] = dp2[i]
        dp1[i+1] %= MOD
        dp2[i+1] %= MOD

    return (dp1[l] + dp2[l]) % MOD main s = sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() s l = len(s) len(s) l MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD ans = main() main() ans
import sys

MOD = 10 ** 9 + 7

s = sys.stdin.readline().rstrip()
l = len(s)

def main():
    dp1 = [0] * (l + 1)
    dp2 = [0] * (l + 1)
    dp2[0] = 1
    for i in range(l):
        dp1[i+1] = dp1[i] * 3
        if s[i] == '1':
            dp1[i+1] += dp2[i]
            dp2[i+1] = dp2[i] * 2
        else:
            dp2[i+1] = dp2[i]
        dp1[i+1] %= MOD
        dp2[i+1] %= MOD

    return (dp1[l] + dp2[l]) % MOD

if __name__ == '__main__':
    ans = main()
    print(ans)