import java.util.*; class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String[] v1 = in.next().split("\\."); String[] v2 = in.next().split("\\."); String ans = "NO"; for(int i = 0; i < 3; i++) { int k = Integer.parseInt(v1[i]); int t = Integer.parseInt(v2[i]); if(i == 0) { if(k > t) { ans = "YES"; break; } else { if(i == 1) { if(k > t) { ans = "YES"; break; } else { if(i == 2) { if(k > t) { ans = "YES"; break; } } } } } } } System.out.println(ans); } }