y, m, d = map(int, input().split()) m = '{:0=2}'.format(m) d = '{:0=2}'.format(d) x = int(str(y) + str(m) + str(d)) print(['NO', 'YES'][19890108 <= x <= 20190430])