import java.util.*;
import java.io.*;

public class Anagrams {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(new File("anagrams.in"));
		PrintWriter out = new PrintWriter("anagrams.out");
		String s1 = in.next();
		in.nextLine();
		String s2 = in.next();
		int l1 = s1.length();
		int l2 = s2.length();
		boolean isAnagram = true;
		if (l1 == l2) {
			for (int i = 0; i < l1; i++) {
				char element = s1.charAt(i);
				//System.out.print(element + " ");
				int counter1 = 0;
				int counter2 = 0;
				for (int j = 0; j < l1; j++) {
					if (element == s1.charAt(j)) {
						counter1 = counter1 + 1;
					}
				}
				//System.out.println(counter1 + " ");
				for (int j = 0; j < l2; j++) {
					if (element == s2.charAt(j)) {
						counter2 = counter2 + 1;
					}
				}
				if (counter1 != counter2) {
					isAnagram = false;
				}
			}
			if ( isAnagram ){
				System.out.println("YES");
				out.print("YES");
			}else{
				System.out.println("NO");
				out.print("NO");
			}			
		}else{
			System.out.println("NO");
			out.print("NO");
		}
		in.close();
		out.close();
	}
}
