defmodule Main do
	def get_rotations(s) do
        s = String.codepoints(s)
        for i  <- 1..length(s) do
            {left, right} = Enum.split(s, i)
            Enum.join(right ++ left)
        end
    end
  def main do
    s =
      IO.read(:line)
      |> String.trim |> String.split
    t =
      IO.read(:line)
      |> String.trim |> String.split
	if get_rotations(s) == t do
    	IO.puts("YES")
    else
    	IO.puts("NO")
    end
    
  end
end
