a = gets.chomp b = gets.chomp list = [] result = true a.chars do |s| if list.include?(s) next else list.push(s) end if a.count(s) != b.count(s) result = false break end end puts result ? "YES" : "NO"