#coding:utf-8 def func(): old=map(int,raw_input().split('.')) hantei=map(int,raw_input().split('.')) if hantei[0] < old[0]: return 'YES' if hantei[0] == old[0]: if hantei[1] < old[1]: return 'YES' elif hantei[1] == old[1]: if hantei[2] <= old[2]: return 'YES' else: return 'NO' else: return 'NO' if old[0] < hantei[0]: return 'NO' if __name__=='__main__': print func()