str1 = gets.chomp.split("") str2 = gets.chomp.split("") str1_uniq = str1.uniq flag = true str1_uniq.each do |str| unless str1.count(str) == str2.count(str) flag = false break end end puts flag == true ? "YES" : "NO"