import java.io.*; import java.util.*; class Main138 { public static boolean check (String[] line1, String[] line2) { int[] ver1 = new int[3]; int[] ver2 = new int[3]; for (int i = 0; i < ver1.length; i++) { ver1[i] = Integer.parseInt(line1[i]); ver2[i] = Integer.parseInt(line2[i]); int sub = ver1[i] - ver2[i]; if (sub != 0) return sub > 0; } return true; } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line1 = br.readLine().split("\\."); String[] line2 = br.readLine().split("\\."); System.out.println(check(line1, line2) ? "YES" : "NO"); } }