coin = [1, 5, 10, 50, 100, 500]
c = gets.split(' ')
for i in 0..c.size - 1
    c[i] = c[i].to_i
end
sum = 0
for i in 0..c.size - 1
    sum += c[i] * coin[i]
end
if sum >= 1000
    puts 1
else
    puts 0
end

