import java.util.*; class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String[] v1 = in.next().split("\\."); String[] v2 = in.next().split("\\."); int[] k = new int[3]; int[] t = new int[3]; for(int i = 0; i < 3; i++) { k[i] = Integer.parseInt(v1[i]); t[i] = Integer.parseInt(v2[i]); } String ans = "NO"; if(k[0] > t[0]) { ans = "YES"; } else if(k[0] == t[0]) { if(k[1] > t[1]) { ans = "YES"; } else if(k[1] == t[1]) { if(k[2] >= t[2]) { ans = "YES"; } } } System.out.println(ans); } }