import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { String[] a = sc.nextLine().split("\\."); String[] b = sc.nextLine().split("\\."); int[] x = new int[3]; int[] y = new int[3]; for (int i=0; i<3; i++) { x[i] = Integer.parseInt(a[i]); y[i] = Integer.parseInt(b[i]); } boolean isOld = true; if (y[0] > x[0]) {isOld = false;} else { if (y[1] > x[1]) {isOld = false;} else { if (y[2] > x[2]) {isOld = false;} } } System.out.println(isOld==true?"YES":"NO"); } }