y, m, d = map(int, input().split()) x = 10000 * y + 100 * m + d print(['NO', 'YES'][19890107 < x < 20190501])