#include <bits/stdc++.h>
using namespace std;
char str[2][200005];
bool fun(int sta, int stb, int len) {
  bool isOk = true;
  for (int i = 0; i < len; i++) {
    if (str[0][sta + i] != str[1][stb + i]) {
      isOk = false;
      break;
    }
  }
  if (isOk) return true;
  if (len % 2 == 1) return false;
  int mp[2][30];
  memset(mp[0], 0, sizeof(mp[0]));
  memset(mp[1], 0, sizeof(mp[1]));
  for (int i = 0; i < len; i++) {
    mp[0][str[0][sta + i] - 'a']++;
    mp[1][str[1][stb + i] - 'a']++;
  }
  for (int i = 0; i < 26; i++)
    if (mp[0][i] != mp[1][i]) return false;
  int mid = len / 2;
  return ((fun(sta, stb, mid) && fun(sta + mid, stb + mid, mid)) ||
          (fun(sta + mid, stb, mid) && fun(sta, stb + mid, mid)));
}
int main() {
  scanf("%s %s", str[0], str[1]);
  printf("%s", (fun(0, 0, strlen(str[0]))) ? "YES" : "NO");
  return 0;
}
