def sumitb2019_a
    m1,d1 = gets.chomp.split(/\s/).map{|x| x.to_i}
    m2,d2 = gets.chomp.split(/\s/).map{|x| x.to_i}

    md = [[1,31], [2,28], [3,31], [4,30], [5,31], [6,30], [7,31], [8,31], [9,30], [10,31], [11,30], [12,31]]
    md.each do |mmdd|
        if mmdd[0] == m1 and mmdd[1] == d1
            puts 1
            exit
        end
    end

    puts 0
end

sumitb2019_a