import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s0 = sc.nextLine(); String [] arr0 = s0.split("\\."); int A0 = Integer.parseInt(arr0[0]); int B0 = Integer.parseInt(arr0[1]); int C0 = Integer.parseInt(arr0[2]); String s1 = sc.nextLine(); String [] arr1 = s1.split("\\."); int A1 = Integer.parseInt(arr1[0]); int B1 = Integer.parseInt(arr1[1]); int C1 = Integer.parseInt(arr1[2]); if(A1>A0){ System.out.println("NO"); }else if(A1B0){ System.out.println("NO"); }else if(B1C0){ System.out.println("NO"); }else if(C1<=C0){ System.out.println("YES"); } } } } }