import java.util.*; import java.math.*; import java.io.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] in1 = sc.next().split("\\."); String[] in2 = sc.next().split("\\."); int[] a1 = new int[3]; int[] a2 = new int[3]; for(int i = 0; i < 3; i++) { a1[i] = Integer.parseInt(in1[i]); a2[i] = Integer.parseInt(in2[i]); } for(int i = 0; i < 3; i++) { if(a1[i] > a2[i]) { System.out.println("YES"); break; } if(a1[i] < a2[i]) { System.out.println("NO"); break; } if(i == 2) { System.out.println("YES"); } } } }