defmodule Main do
  def main do
    s =
      IO.read(:line)
      |> String.trim |> String.to_charlist
    t =
      IO.read(:line)
      |> String.trim |> String.to_charlist
    [_shead, stail] = s
    [_thead, ttail] = t
	if List.first(s) == List.last(t) and List.last(s) == List.first(t) and List.first(stail) == List.first(ttail) do
    	IO.puts("YES")
    else
    	IO.puts("NO")
    end
    
  end
end
