Y, M, D = map(int ,input().split()) print(['NO', 'YES'][19890107 < Y*10000 + M*100 + D < 20190430])