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(new File("anagrams.out"));
        String s1 = in.next();
        String s2 = in.next();
        int len1 = s1.length(), len2 = s2.length();
        boolean res = true;
        if(len1 == len2){
          char[] c1 = new char[len1];
          char[] c2 = new char[len2];
          for(int i = 0; i < len1; ++i) {
            c1[i] = s1.charAt(i);
            c2[i] = s2.charAt(i);
          }
          for(int j=0;j<len1-1;j++)
           for(int i=0;i<len1-1;i++) {
             if(c1[i]>c1[i+1])
             {
                char t=c1[i];
                c1[i]=c1[i+1];
                c1[i+1]=t;
             }
             if(c2[i]>c2[i+1])
             {
                char t=c2[i];
                c2[i]=c2[i+1];
                c2[i+1]=t;
             }
           }
          for(int i = 0; (i < len1) && (res); ++i)
              if(c1[i] != c2[i])
                  res = false;
        }
        else
            res = false;
        if(res)
          out.print("YES");
        else
          out.print("NO");
        in.close();
        out.close();
    }
}
