import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner koko = new Scanner(System.in); String a = koko.next(); String b = koko.next(); String[] ah = a.split("\\."); String[] bh = b.split("\\."); int[] c = new int[6]; for(int i=0; i<3; i++){ c[i] = Integer.parseInt(ah[i]); c[i+3] = Integer.parseInt(bh[i]); } if(c[3]>c[0]){ System.out.println("NO"); }else if(c[3]c[1]){ System.out.println("NO"); }else if(c[4]c[2]){ System.out.println("NO"); }else if(c[5]<=c[2]){ System.out.println("YES"); } } }