#coding:utf-8 old=raw_input().split('.') hantei=raw_input().split('.') if hantei[0] < old[0]: print 'YES' if hantei[0] == old[0]: if hantei[1] < old[1]: print 'YES' elif hantei[1] == old[1]: if hantei[2] <= old[2]: print 'YES' else: print 'NO' else: print 'NO' if old[0] < hantei[0]: print 'NO'