require 'date' d = Date.new(*gets.split.map(&:to_i)) l = Date.new(1989,1,8) r = Date.new(2019,4,30) puts (l<=d&&d<=r ? "YES" : "NO")