#include <bits/stdc++.h>
using namespace std;
int sum1[200005][30];
int sum2[200005][30];
string s;
string l;
bool test(int i, int j, int u, int v) {
  if ((j - i) % 2 == 0) {
    for (int x = 0; x <= j - i; ++x)
      if (s[x + i - 1] != l[x + u - 1]) return 0;
    return 1;
  }
  for (int x = 0; x <= 'z' - 'a'; ++x) {
    if (sum1[j][x] - sum1[i - 1][x] != sum2[v][x] - sum2[u - 1][x]) return 0;
  }
  if (j - i == 0 && v - u == 0) return 1;
  if (test(i, (i + j) / 2, u, (v + u) / 2) &&
      test((i + j) / 2 + 1, j, (v + u) / 2 + 1, v))
    return 1;
  else if (test(i, (i + j) / 2, (v + u) / 2 + 1, v) &&
           test((i + j) / 2 + 1, j, u, (v + u) / 2))
    return 1;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> s;
  cin >> l;
  if (s.size() != l.size()) {
    cout << "NO\n" << endl;
    return 0;
  }
  if (s.size() % 2 == 1) {
    for (int x = 0; x < s.size(); ++x)
      if (s[x] != l[x]) {
        cout << "NO" << endl;
        return 0;
      }
    cout << "YES" << endl;
    return 0;
  }
  for (int x = 1; x <= s.size(); ++x) {
    for (int y = 0; y <= 'z' - 'a'; ++y) {
      sum1[x][y] = sum1[x - 1][y] + (s[x - 1] == 'a' + y);
    }
  }
  for (int x = 1; x <= l.size(); ++x) {
    for (int y = 0; y <= 'z' - 'a'; ++y) {
      sum2[x][y] = sum2[x - 1][y] + (l[x - 1] == 'a' + y);
    }
  }
  if (test(1, s.size(), 1, s.size()))
    cout << "YES\n";
  else
    cout << "NO" << endl;
}
