a = list(map(int, input().split("."))) b = list(map(int, input().split("."))) ans = "NO" if a[0] > b[0]: ans = "YES" elif a[0] == b[0]: if a[1] > b[1]: ans = "YES" elif a[1] == b[1]: if a[2] >= b[2]: ans = "YES" print(ans)