s0, s1 = io.read("*l", "*l") v0, v1 = {}, {} for j in string.gmatch(s0, "(%d)") do table.insert(v0, j) end for j in string.gmatch(s1, "(%d)") do table.insert(v1, j) end if(v1[1] < v0[1]) then print("YES") elseif(v0[1] < v1[1]) then print("NO") elseif(v1[2] < v0[2]) then print("YES") elseif(v0[2] < v1[2]) then print("NO") elseif(v1[3] <= v0[3]) then print("YES") else print("NO") end