package yukiCoder; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class No00069 { public static void main(String[] args) { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); try { String input1 = bufferedReader.readLine(); String input2 = bufferedReader.readLine(); System.out.println(isEqual(input1, input2) ? "YES" : "NO"); } catch (IOException e) { e.printStackTrace(); } } public static Boolean isEqual(String input1 , String input2) { String[] indexArray = new String[input1.length()]; for(int i = 0; i < input2.length() ; i++) { String digit = String.valueOf(input2.charAt(i)); int index = input1.indexOf(digit); if (index != -1) { if(indexArray[index] == null) indexArray[index] = digit; } } StringBuilder builder = new StringBuilder(); for (int i = 0 ; i < indexArray.length ; i++) { builder.append(indexArray[i]); } return input1.equals(builder.toString()) ? true : false; } }