import java.util.*

object MainKt {
	val mod = 1000000007

	@JvmStatic
	fun main(args: Array<String>) {
		val scanner = Scanner(System.`in`)
		val l = scanner.next()
		val cs = l.toCharArray()
		var ans: Long = 0
		var mul=0
		for (i in 0..cs.size-1){
			if (i!=cs.size-1){
				if (cs[i]=='1'){
					ans = (ans+(pow(2, mul)*pow(3, cs.size-1-i)))%mod
					mul++
				}
			}else{
				ans = (ans+pow(2, mul)*( if(cs[i]=='0') 1 else 3 ))%mod
			}
		}
		println(ans)
	}

	fun pow(base: Int, exp: Int): Long{
		var e = exp
		var p= base.toLong()
		var ans: Long = 1
		while(e>0){
			if (e%2==1){
				ans = (ans*p)%mod
			}
			p = (p*p)%mod
			e/=2
		}
		return ans
	}

}