/*
 * Created on 01.12.2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

/**
 * @author B21
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
import java.io.*;
import java.lang.*;
import java.math.*;
import java.util.*;

public class AncientChiper {

	public static void main(String[] args) throws IOException{
		StreamTokenizer in = new StreamTokenizer(new FileReader("ancient.in"));
		in.nextToken();
		String s = in.sval;
		while (in.nextToken() != StreamTokenizer.TT_WORD) ;
		String s2 = in.sval;
		char[] carr = (s.toUpperCase()).toCharArray();
		Arrays.sort(carr);
		char[] carr2 = (s2.toUpperCase()).toCharArray();
		Arrays.sort(carr2);
		int[] letts = new int[26];
		int[] lettd = new int[26];
		for (int i=1; i<s.length();i++){
			letts[(carr[i]-'A')]++;
			lettd[(carr2[i]-'A')]++;
			} 
		Arrays.sort(letts);
		Arrays.sort(lettd);
		FileWriter fw = new FileWriter("ancient.out");
		if (Arrays.equals(letts,lettd)){
			fw.write("YES");
			} else {fw.write("NO");}
		fw.close();
	}
}
