require "date"
ma= gets.chomp.split(" ").map(&:to_i)
mb= gets.chomp.split(" ").map(&:to_i)
puts day_a=Date.new(2019,ma[0],ma[1])
puts day_b=Date.new(2019,mb[0],mb[1])
if (day_a)+1 == day_b && mb[1]==1
    puts 1
else
    puts 0
end