Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 

  1. They are equal. 
  2. If we split string a into two halves of the same size a1 and a2, and string b into two halves of the same size b1 and b2, then one of the following is correct: 
    1. a1 is equivalent to b1, and a2 is equivalent to b2
    2. a1 is equivalent to b2, and a2 is equivalent to b1



As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent.

Gerald has already completed this home task. Now it's your turn!

Input

The first two lines of the input contain two strings given by the teacher. Each of them has the length from 1 to 200 000 and consists of lowercase English letters. The strings have the same length.

Output

Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise.

Examples

Input

aaba
abaa


Output

YES


Input

aabb
abab


Output

NO

Note

In the first sample you should split the first string into strings "aa" and "ba", the second one — into strings "ab" and "aa". "aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab" = "a" + "b", "ba" = "b" + "a".

In the second sample the first string can be splitted into strings "aa" and "bb", that are equivalent only to themselves. That's why string "aabb" is equivalent only to itself and to string "bbaa".
/**
 * Created by mo on 6/12/17.
 */

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

import static java.lang.Math.*;

public class EquivalentStringsCF {
    public static boolean debug = false;
    static StringBuilder sb;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //FastScanner sc = new FastScanner();
        String x = findBest(sc.next());
        String y = findBest(sc.next());
        int len = x.length() + y.length();
        String[] strs = substringPopulate(x, y);
        long[] hashes = new long[4];
        for (int i = 0; i < 4; i++) {
            HashStructure hsh = new HashStructure(strs[i]);
            hashes[i] = hsh.getHashEntireString();
        }
        if (debug) System.out.println(Arrays.toString(hashes));
        System.out.println(x.equals(y) || checkValid(hashes) ? "YES" : "NO");
    }
    public static String findBest(String s) {
        if (s.length() % 2 == 1) return s;
        String s1 = findBest(s.substring(0, s.length() / 2));
        String s2 = findBest(s.substring(s.length() / 2, s.length()));
        if (s1.compareTo(s2) < 0) return s1 + s2;
        else return s2 + s1;
    }
    public static boolean checkValid(long[] hashes) {
        return (hashes[0] == hashes[2] && hashes[1] == hashes[3]) ||
                (hashes[0] == hashes[3] && hashes[1] == hashes[2]);
    }
    public static String[] substringPopulate(String x, String y) {
        int len = x.length();
        String[] strs = new String[4];
        String a1 = x.substring(0, len / 2);
        String a2 = x.substring(len / 2, len);
        String b1 = y.substring(0, len / 2);
        String b2 = y.substring(len / 2, len);
        strs[0] = a1;
        strs[1] = a2;
        strs[2] = b1;
        strs[3] = b2;
        return strs;
    }
    public static String sortByChar(String s) {
        char[] ch = s.toCharArray();
        Arrays.sort(ch);
        sb = new StringBuilder();
        for (char c : ch)
            sb.append(c);
        return sb.toString();
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }

        public FastScanner() {
            this(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }

        long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextLong();
            }
            return a;
        }
    }

    //HashStructure allows the comparison of strings in O(1), after the hashes have been created.
    //The chance of two strings colliding is 1E-16, with default settings.
    //For two strings of size 1E6, you can compare 10^6 hashes with another 10^6 hashes. We have 1E12 comparisons, which means a chance of roughly 1E12/1E16 = 1E-4 = 0.0001 chance of failure.
    //All methods are O(n), where n is the length of the string.
    public static class HashStructure{
        String str;
        long prime = 10000000000000061l;
        long base = 257;
        long baseInv = 2412451361867719l;

        //Use this constructor with caution.
        //If you specify different values for base and prime, you must do that for all of the strings you compare with.
        //Prime and base should be relatively prime.
        //Base should be larger than 10^16, but smaller than (9*10^18)/base
        public HashStructure(String in, long base, long prime){
            str = in;
            this.base = base;
            this.prime = prime;

            //comment out this check before submit if time is important
            checkPrimeBase(); //If this fails, pick a different prime.

        }

        //default settings
        //use this for all string hashing, unless you have reason not to
        public HashStructure(String in){
            str = in;
            //checkPrimeBase();
        }


        //Confirms that the powers of base do not repeat in the first million values. If the powers of base repeat mod prime, using that base and prime has additional risk of collision.
        public void checkPrimeBase(){
            long start = 1;
            HashSet<Long> checkBase = new HashSet<Long>();
            checkBase.add(start);
            for(int a = 0; a < 1000000; a++){
                start *= base;
                start %= prime;
                checkBase.add(start);
            }
            //If this condition is true, A...Z == B...Y == C...X == D...W etc.
            //This is bad.
            if(checkBase.size() != 1000001){
                throw new Error("Prime and base are dangerous; collisions more likely than random chance. Pick another.");
            }
            if(base*prime/prime != base){
                throw new Error("Product of prime and base overflows long; pick a lower prime, or a lower base. Proceed with caution.");
            }
        }

        //return hash of the entire string
        public long getHashEntireString(){
            long hashStart = 0;
            //Iterate across string, shifting and adding.
            for(int a = 0; a < str.length(); a++){
                hashStart *= base;
                hashStart += str.charAt(a);
                hashStart %= prime;
            }
            return hashStart;
        }

        //returns an ArrayList of the hashes of all prefix.
        //If blankstring is true, the list will start with 0, the hash of blankstring.
        //returned in order from shortest string to longest string
        public ArrayList<Long> getAllPrefixHashes(boolean blankString){
            ArrayList<Long> output = new ArrayList<Long>();
            long hashStart = 0;
            //If hash of 0 length string is desired, add to output
            if(blankString){
                output.add(hashStart);
            }

            //Add each character one at a time. O(n) time.
            for(int a = 0; a < str.length(); a++){
                //Shift all characters left
                hashStart *= base;
                //Add new character
                hashStart += str.charAt(a);
                //Ensure hash stays in range
                hashStart %= prime;
                //Add to output
                output.add(hashStart);
            }
            return output;
        }

        //returns an ArrayList of the hashes of all suffix.
        //If blankstring is true, the list will start with 0, the hash of blankstring.
        //returned in order from shortest string to longest string. (right to left)
        public ArrayList<Long> getAllSuffixHashes(boolean blankString){
            ArrayList<Long> output = new ArrayList<Long>();

            //First, compute the hash of the entire string: O(n)
            long hashStart = 0;
            for(int a = 0; a < str.length(); a++){
                hashStart *= base;
                hashStart += str.charAt(a);
                hashStart %= prime;
            }

            //Compute the powers of base using dynamic programming. O(n)
            ArrayList<Long> powersOfBase = new ArrayList<Long>();
            long hashMult = 1;
            for(int a = 0; a < str.length(); a++){
                powersOfBase.add(hashMult);
                hashMult *= base;
                hashMult %= prime;
            }

            //Use the generated powers to remove characters from the left, one at a time
            for(int a = 0; a < str.length(); a++){
                output.add(hashStart);
                hashStart -= powersOfBase.get(str.length()-a-1)*str.charAt(a);
                hashStart %= prime;
                hashStart += prime;
                hashStart %= prime;
            }

            //If the suffix of length 0 is desired, output hashStart (which should be 0)
            if(blankString){
                output.add(hashStart);
            }


            //hashStart should always be 0
            //If not, unrecoverable
            if(hashStart != 0){
                throw new Error("Suffix Hashes Busted");
            }

            //reverse order of the output, so the hashes are in order from smallest suffix to largest suffix.
            Collections.reverse(output);
            return output;
        }

        //Returns a list of hashes of all substrings of length x.
        //Ordered from left to right.
        public ArrayList<Long> getAllXSubstringHashes(int x){

            //First, compute the xth power of base. O(n)
            long xthBasePow = 1;
            for(int a = 0; a < x; a++){
                xthBasePow *= base;
                xthBasePow %= prime;
            }

            ArrayList<Long> output = new ArrayList<Long>();

            //Build the first hash of length X. O(n)
            long hashStart = 0;
            for(int a = 0; a < x; a++){
                hashStart *= base;
                hashStart += str.charAt(a);
                hashStart %= prime;
            }
            output.add(hashStart);


            //Iterate across the rest of the string, adding characters on the right and removing characters on the left. O(n)
            for(int a = x; a < str.length(); a++){

                //Shift all characters the the left
                hashStart *= base;
                hashStart %= prime;

                //Add a character on the right
                hashStart += str.charAt(a);
                hashStart %= prime;

                //Subtract a character on the far left, using the precomputed basePow
                hashStart -= str.charAt(a-x)*xthBasePow;

                //Ensure hashStart stays in the range [0, prime-1]
                hashStart %= prime;
                hashStart += prime;
                hashStart %= prime;
                output.add(hashStart);
            }
            return output;
        }
    }
}
