/*
 * 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{
		FileReader r = new FileReader("ancient.in");
		StringBuffer x = new StringBuffer();
		for (;;) {
			int c = r.read();
			if (c >= 'A')
				x.append((char) c);
			else
				break;
		}
		String s = x.toString();
		x.setLength(0);
		r.read();		
		for (;;) {
			int c = r.read();
			if (c >= 'A')
				x.append((char) c);
			else
				break;
		}	
		
		String s2 = x.toString();
		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=0; 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();
	}
}
