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".
import java.io.*;
import java.util.*;




public class Main {
	
	static InputReader in = new InputReader(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	
	
	static char[] a, b;
	static int n;
	static HashMap<String, Boolean> memo = new HashMap<>();
	
	public static void main(String[] args) {
		
		String inputA = in.readString();
		String inputB = in.readString();
		a = inputA.toCharArray();
		b = inputB.toCharArray();
		
		n = a.length;
		
		if(n % 2 == 1) {
			System.out.println( inputA.equals(inputB) ? "YES" : "NO" );
			return;
		}
		
		System.out.println( equi(inputA, inputB) ? "YES" : "NO" );
//		System.out.println( equi(0, n-1, 0, n-1) ? "YES" : "NO" );
		
		out.close();
	}
	
	static boolean equi(String a, String b) {
		if(a.compareTo(b) > 0) {
			String tmp = a;
			a = b;
			b = tmp;
		}
		String key = a + b;
		if(memo.containsKey(key)) {
			return memo.get(key);
		}
			
		
		boolean ret = false;
		if(a.equals(b))
			ret = true;
		else if(a.length() % 2 == 1)
			ret = false;
		else {
			int h = a.length() / 2;
			String al = a.substring(0, h);
			String ar = a.substring(h);
			
			String bl = b.substring(0, h);
			String br = b.substring(h);
			
			ret = equi(al, bl) && equi(ar, br) || equi(al, br) && equi(ar, bl);
		}
		memo.put(key, ret);
		return ret;
	}
	
	static boolean equi(int al, int ar, int bl, int br) {
		int len = ar - al + 1;
		if(len == 1) {
			return a[al] == b[bl];
		}
		
//		ArrayList<Integer> hash = new ArrayList<>();
//		hash.add(al);
//		hash.add(ar);
//		hash.add(bl);
//		hash.add(ar);
//		
//		if(memo.containsKey(hash))
//			return memo.get(hash);
		
		boolean equal = true;
		for(int i=0; i<len; ++i) {
			if(a[al + i] != b[bl + i]) {
				equal = false;
				break;
			}
		}
		if(equal)
			return true;
		
		if(len % 2 == 1) 
			return false;
		
		int ah = (al + ar) / 2;
		int bh = (bl + br) / 2;
		boolean ret = (equi(al, ah, bl, bh) && equi(ah + 1, ar, bh + 1, br))
				|| (equi(al, ah, bh+1, br) && equi(ah+1, ar, bl, bh));
		
//		memo.put(hash, ret);
		return ret;
	}
	
}


class InputReader {

	private final InputStream stream;
	private final byte[] buf = new byte[8192];
	private int curChar, snumChars;

	public InputReader(InputStream st) {
		this.stream = st;
	}

	public int read() {
		if (snumChars == -1)
			throw new InputMismatchException();
		if (curChar >= snumChars) {
			curChar = 0;
			try {
				snumChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (snumChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int nextInt() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public long nextLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public int[] nextIntArray(int n) {
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public String nextLine() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

	public boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}

}