import java.util.*; class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { String[] a = sc.next().split("\\.",0); String[] b = sc.next().split("\\.",0); String ans = "YES"; for (int i=0; i<3; i++) { int t1 = Integer.parseInt(b[i]); int t2 = Integer.parseInt(a[i]); if (t1 < t2) { ans = "YES"; break; } else if (t1 > t2) { ans = "NO"; break; } } System.out.println(ans); } }