N = gets.strip.to_i(2)

def popcount(num)
  cnt = 0
  bits = num & 0x00000000ffffffff
  while bits != 0
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555)
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333)
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f)
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff)
    cnt += (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff)
    num >>= 32
    bits = num & 0x00000000ffffffff
  end
  cnt
end

num = 0
0.upto(N) do |i|
  num += 2**popcount(i)
end

S=10**9 + 7

puts num % S