#include<stdio.h>
int main()
{
	int rem,n,i,arr[100005],sum=0,count[10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&arr[i]);
	for(i=0;i<n;i++)
		count[arr[i]]++;
	sum=sum+count[4];
	if(count[3]>=count[1])
		sum=sum+count[3];
	else
	{
		sum=sum+count[3];
		rem=count[1]-count[3];
	}
	sum=sum+count[2]/2;
	if(count[2]%2!=0&&rem<=2)
		sum=sum+1;
	if(count[2]==0)
	{
		if(rem<=4)
			sum=sum+1;
		else if(rem%4==0)
			sum=sum+rem/4;
		else
			sum=sum+rem/4+1;
	}
	if(rem>=3&&count[2]!=0)
	{
		count[1]=count[1]-2;
		if(count[1]%4!=0)
			sum=sum+count[1]/4+1;
		else
			sum=sum+count[1]/4;
	}
	printf("%d\n",sum);
	return 0;
}


#include<stdio.h>
int main()
{
	int rem,n,i,arr[100005],sum=0,count[10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&arr[i]);
	for(i=0;i<n;i++)
		count[arr[i]]++;
	sum=sum+count[4];
	if(count[3]>=count[1])
		sum=sum+count[3];
	else
	{
		sum=sum+count[3];
		rem=count[1]-count[3];
	}
	sum=sum+count[2]/2;
	if(count[2]%2!=0&&rem<=2)
		sum=sum+1;
	if(rem>=3)
	{
		count[1]=count[1]-2;
		sum=sum+count[1]/4+1;
	}
	printf("%d\n",sum);
	return 0;
}


#include<stdio.h>
int main()
{
	int rem,n,i,arr[100005],sum=0,count[10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&arr[i]);
	for(i=0;i<n;i++)
		count[arr[i]]++;
	sum=sum+count[4];
	if(count[3]>=count[1])
		sum=sum+count[3];
	else
	{
		sum=sum+count[3];
		rem=count[1]-count[3];
	}
	sum=sum+count[2]/2;
	if(count[2]%2!=0&&rem<=2)
		sum=sum+1;
	if(count[2]==0&&rem!=0)
	{
		if(rem<=4)
			sum=sum+1;
		else if(rem%4==0)
			sum=sum+rem/4;
		else
			sum=sum+rem/4+1;
	}
	if(rem>=3&&count[2]!=0)
	{
		count[1]=count[1]-2;
		if(count[1]%4!=0)
			sum=sum+count[1]/4+1;
		else
			sum=sum+count[1]/4;
	}
	printf("%d\n",sum);
	return 0;
}


#include<stdio.h>
int main()
{
	int rem,n,i,arr[100005],sum=0,count[10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&arr[i]);
	//////////////////////////////
	for(i=0;i<n;i++)
		count[arr[i]]++;
	sum=sum+count[4];
	if(count[3]>=count[1])
		sum=sum+count[3];
	else
	{
		sum=sum+count[3];
		rem=count[1]-count[3];
	}
	sum=sum+count[2]/2;
	if(count[2]%2!=0&&rem<=2)
		sum=sum+1;
	if(count[2]==0&&rem>=1)
	{
		if(rem<=4)
			sum=sum+1;
		else if(rem%4==0)
			sum=sum+rem/4;
		else
			sum=sum+rem/4+1;
	}
	if(rem>=3&&count[2]!=0)
	{
		count[1]=count[1]-2;
		if(count[1]%4!=0)
			sum=sum+count[1]/4+1;
		else
			sum=sum+count[1]/4;
	}
	printf("%d\n",sum);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int number_of_groups;
    int number_of_taxis = 0;
    scanf("%d", &number_of_groups);
    int number_of_members[number_of_groups + 5];
    for(int i = 0; i < number_of_groups; i++){
        scanf("%d", &number_of_members[i]);
    }
    for(int i = 0; i < number_of_groups; i++){
        if(number_of_members[i] == 4){
            number_of_members[i] = 0;
            number_of_taxis++;
        }

        else if(number_of_members[i] == 3){
            for(int t = 0 ; t < number_of_groups; t++){
                if(number_of_members[t] == 1){
                    number_of_members[i] = 0;
                    number_of_members[t] = 0;
                    number_of_taxis++;
                    break;
                }
            }
        }
        else if(number_of_members[i] == 2){
            for(int t = 0; t < number_of_groups; t++){
                if((number_of_members[t] == 2) && ( i != t)){
                    number_of_members[i] = 0;
                    number_of_members[t] = 0;
                    number_of_taxis++;
                    break;
                }

            }
        }
        //printf("%d\n", number_of_taxis);
    }

    int left_ones;
    int a,b,c,d;
    for(int i =  0; i < number_of_groups; i++){
        if(number_of_members[i] == 1){
            left_ones = 1;
            for(int t = 0;  t < number_of_groups; t++){
                if((number_of_members[t] == 1) && (i != t)){
                    left_ones++;
                    if(left_ones == 2){
                        a = t;
                    }
                    else if(left_ones == 3){
                        b = t;
                    }
                    else if(left_ones == 4){
                        c = t;
                        number_of_members[i] = 0;
                        number_of_members[a] = 0;
                        number_of_members[b] = 0;
                        number_of_members[c] = 0;
                        number_of_taxis++;
                    }
                }
                //printf("%d\n", number_of_taxis);
            }
        }
    }
    //printf("%d\n", number_of_taxis);
    left_ones = 0;
    for(int i =  0; i < number_of_groups; i++){
        if(number_of_members[i] == 2){
            for(int t = 0;  t < number_of_groups; t++){
                if(number_of_members[t] == 1){
                    left_ones++;
                    if(left_ones == 1){
                        a = t;
                    }
                    else if(left_ones == 2){
                        b = t;
                    }
                }
                if(left_ones == 2){
                    left_ones = 0;
                    number_of_members[i] = 0;
                    number_of_members[a] = 0;
                    number_of_members[b] = 0;
                    number_of_taxis++;
                }
            }
        }
    }

    //printf("%d\n", number_of_taxis);
    /*for(int i = 0; i < number_of_groups; i++){
        for(int j = 0; j < number_of_groups; j++){
            if((number_of_members[i] + number_of_members[j] <= 4) && (i != j) && (number_of_members[i] != 0) && (number_of_members[j] != 0)){
                number_of_members[i] = 0;
                number_of_members[j] = 0;
                number_of_taxis++;
            }
        }
    }*/

    //printf("%d\n", number_of_taxis);

    for(int i = 0; i < number_of_groups; i++){
        for(int j = 0; j < number_of_groups; j++){
            for(int k = 0; k < number_of_groups; k++){
                if((number_of_members[i] + number_of_members[j] + number_of_members[k] <= 4) && (i != j) && (i != k) && (j != k) && (number_of_members[i] + number_of_members[j] + number_of_members[k] != 0)){
                    number_of_members[i] = 0;
                    number_of_members[j] = 0;
                    number_of_members[k] = 0;
                    number_of_taxis++;
                }
            }
        }
    }

    for(int i = 0; i < number_of_groups; i++){
        if(number_of_members[i] != 0){
            number_of_taxis++;
        }
    }
    printf("%d", number_of_taxis);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int number_of_groups;
    int number_of_taxis = 0;
    scanf("%d", &number_of_groups);
    int number_of_members[number_of_groups + 5];
    for(int i = 0; i < number_of_groups; i++){
        scanf("%d", &number_of_members[i]);
    }
    for(int i = 0; i < number_of_groups; i++){
        if(number_of_members[i] == 4){
            number_of_members[i] = 0;
            number_of_taxis++;
        }

        else if(number_of_members[i] == 3){
            for(int t = 0 ; t < number_of_groups; t++){
                if(number_of_members[t] == 1){
                    number_of_members[i] = 0;
                    number_of_members[t] = 0;
                    number_of_taxis++;
                    break;
                }
            }
        }
        else if(number_of_members[i] == 2){
            for(int t = 0; t < number_of_groups; t++){
                if((number_of_members[t] == 2) && ( i != t)){
                    number_of_members[i] = 0;
                    number_of_members[t] = 0;
                    number_of_taxis++;
                }
                break;
            }
        }
        //printf("%d\n", number_of_taxis);
    }

    int left_ones = 0;
    int a,b,c,d;
    for(int i =  0; i < number_of_groups; i++){
        if(number_of_members[i] == 1){
            for(int t = 0;  t < number_of_groups; t++){
                if(number_of_members[t] == 1){
                    left_ones++;
                    if(left_ones == 1){
                        a = t;
                    }
                    else if(left_ones == 2){
                        b = t;
                    }
                    else if(left_ones == 3){
                        c = t;
                    }
                    else if(left_ones == 4){
                        d = t;
                    }
                }
                if(left_ones == 4){
                    left_ones = 0;
                    number_of_members[a] = 0;
                    number_of_members[b] = 0;
                    number_of_members[c] = 0;
                    number_of_members[d] = 0;
                    number_of_taxis++;
                }
            }
        }
    }

    left_ones = 0;
    for(int i =  0; i < number_of_groups; i++){
        if(number_of_members[i] == 2){
            for(int t = 0;  t < number_of_groups; t++){
                if(number_of_members[t] == 1){
                    left_ones++;
                    if(left_ones == 1){
                        a = t;
                    }
                    else if(left_ones == 2){
                        b = t;
                    }
                }
                if(left_ones == 2){
                    left_ones = 0;
                    number_of_members[a] == 0;
                    number_of_members[b] == 0;
                    number_of_taxis++;
                }
            }
        }
    }

    //printf("%d\n", number_of_taxis);
    for(int i = 0; i < number_of_groups; i++){
        for(int j = 0; j < number_of_groups; j++){
            if((number_of_members[i] + number_of_members[j] <= 4) && (i != j) && (number_of_members[i] != 0) && (number_of_members[j] != 0)){
                number_of_members[i] = 0;
                number_of_members[j] = 0;
                number_of_taxis++;
            }
        }
    }
    for(int i = 0; i < number_of_groups; i++)
        if(number_of_members[i] != 0){
            number_of_taxis++;
        }
    printf("%d", number_of_taxis);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int number_of_groups;
    int number_of_taxis = 0;
    scanf("%d", &number_of_groups);
    int number_of_members[number_of_groups + 5];
    for(int i = 0; i < number_of_groups; i++){
        scanf("%d", &number_of_members[i]);
    }
    for(int i = 0; i < number_of_groups; i++){
        if(number_of_members[i] == 4){
            number_of_members[i] = 0;
            number_of_taxis++;
        }

        else if(number_of_members[i] == 3){
            for(int t = 0 ; t < number_of_groups; t++){
                if(number_of_members[t] == 1){
                    number_of_members[i] = 0;
                    number_of_members[t] = 0;
                    number_of_taxis++;
                    break;
                }
            }
        }
        else if(number_of_members[i] == 2){
            for(int t = 0; t < number_of_groups; t++){
                if((number_of_members[t] == 2) && ( i != t)){
                    number_of_members[i] = 0;
                    number_of_members[t] = 0;
                    number_of_taxis++;
                    break;
                }

            }
        }
        //printf("%d\n", number_of_taxis);
    }

    int left_ones;
    int a,b,c,d;
    for(int i =  0; i < number_of_groups; i++){
        if(number_of_members[i] == 1){
            left_ones = 1;
            for(int t = 0;  t < number_of_groups; t++){
                if((number_of_members[t] == 1) && (i != t)){
                    left_ones++;
                    if(left_ones == 2){
                        a = t;
                    }
                    else if(left_ones == 3){
                        b = t;
                    }
                    else if(left_ones == 4){
                        c = t;
                        number_of_members[i] = 0;
                        number_of_members[a] = 0;
                        number_of_members[b] = 0;
                        number_of_members[c] = 0;
                        number_of_taxis++;
                    }
                }
                //printf("%d\n", number_of_taxis);
            }
        }
    }
    //printf("%d\n", number_of_taxis);
    left_ones = 0;
    for(int i =  0; i < number_of_groups; i++){
        if(number_of_members[i] == 2){
            for(int t = 0;  t < number_of_groups; t++){
                if(number_of_members[t] == 1){
                    left_ones++;
                    if(left_ones == 1){
                        a = t;
                    }
                    else if(left_ones == 2){
                        b = t;
                    }
                }
                if(left_ones == 2){
                    left_ones = 0;
                    number_of_members[i] = 0;
                    number_of_members[a] = 0;
                    number_of_members[b] = 0;
                    number_of_taxis++;
                }
            }
        }
    }

    //printf("%d\n", number_of_taxis);
    for(int i = 0; i < number_of_groups; i++){
        for(int j = 0; j < number_of_groups; j++){
            if((number_of_members[i] + number_of_members[j] <= 4) && (i != j) && (number_of_members[i] != 0) && (number_of_members[j] != 0)){
                number_of_members[i] = 0;
                number_of_members[j] = 0;
                number_of_taxis++;
            }
        }
    }

    for(int i = 0; i < number_of_groups; i++)
        if(number_of_members[i] != 0){
            number_of_taxis++;
        }
    printf("%d", number_of_taxis);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int number_of_groups;
    int number_of_taxis = 0;
    scanf("%d", &number_of_groups);
    int number_of_members[number_of_groups + 5];
    for(int i = 0; i < number_of_groups; i++){
        scanf("%d", &number_of_members[i]);
    }
    for(int i = 0; i < number_of_groups; i++){
        if(number_of_members[i] == 4){
            number_of_members[i] = 0;
            number_of_taxis++;
        }

        else if(number_of_members[i] == 3){
            for(int t = 0 ; t < number_of_groups; t++){
                if(number_of_members[t] == 1){
                    number_of_members[i] = 0;
                    number_of_members[t] = 0;
                    number_of_taxis++;
                    break;
                }
            }
        }
        else if(number_of_members[i] == 2){
            for(int t = 0; t < number_of_groups; t++){
                if((number_of_members[t] == 2) && ( i != t)){
                    number_of_members[i] = 0;
                    number_of_members[t] = 0;
                    number_of_taxis++;
                    break;
                }

            }
        }
        //printf("%d\n", number_of_taxis);
    }

    int left_ones;
    int a,b,c,d;
    for(int i =  0; i < number_of_groups; i++){
        if(number_of_members[i] == 1){
            left_ones = 1;
            for(int t = 0;  t < number_of_groups; t++){
                if((number_of_members[t] == 1) && (i != t)){
                    left_ones++;
                    if(left_ones == 2){
                        a = t;
                    }
                    else if(left_ones == 3){
                        b = t;
                    }
                    else if(left_ones == 4){
                        c = t;
                        number_of_members[i] = 0;
                        number_of_members[a] = 0;
                        number_of_members[b] = 0;
                        number_of_members[c] = 0;
                        number_of_taxis++;
                    }
                }
                //printf("%d\n", number_of_taxis);
            }
        }
    }
    //printf("%d\n", number_of_taxis);
    left_ones = 0;
    for(int i =  0; i < number_of_groups; i++){
        if(number_of_members[i] == 2){
            for(int t = 0;  t < number_of_groups; t++){
                if(number_of_members[t] == 1){
                    left_ones++;
                    if(left_ones == 1){
                        a = t;
                    }
                    else if(left_ones == 2){
                        b = t;
                    }
                }
                if(left_ones == 2){
                    left_ones = 0;
                    number_of_members[i] = 0;
                    number_of_members[a] = 0;
                    number_of_members[b] = 0;
                    number_of_taxis++;
                }
            }
        }
    }

    //printf("%d\n", number_of_taxis);
    for(int i = 0; i < number_of_groups; i++){
        for(int j = 0; j < number_of_groups; j++){
            if((number_of_members[i] + number_of_members[j] <= 4) && (i != j) && (number_of_members[i] != 0) && (number_of_members[j] != 0)){
                number_of_members[i] = 0;
                number_of_members[j] = 0;
                number_of_taxis++;
            }
        }
    }

    //printf("%d\n", number_of_taxis);

    for(int i = 0; i < number_of_groups; i++){
        for(int j = 0; j < number_of_groups; j++){
            for(int k = 0; k < number_of_groups; k++){
                if((number_of_members[i] + number_of_members[j] + number_of_members[k] <= 4) && (i != j) && (i != k) && (j != k) && (number_of_members[i] + number_of_members[j] + number_of_members[k] != 0)){
                    number_of_members[i] = 0;
                    number_of_members[j] = 0;
                    number_of_members[k] = 0;
                    number_of_taxis++;
                }
            }
        }
    }

    //printf("%d\n", number_of_taxis);

    for(int i = 0; i < number_of_groups; i++){
        if(number_of_members[i] != 0){
            number_of_taxis++;
        }
    }
    printf("%d", number_of_taxis);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int number_of_groups;
    int number_of_taxis = 0;
    scanf("%d", &number_of_groups);
    int number_of_members[number_of_groups + 5];
    for(int i = 0; i < number_of_groups; i++){
        scanf("%d", &number_of_members[i]);
    }
    for(int i = 0; i < number_of_groups; i++){
        if(number_of_members[i] == 4){
            number_of_members[i] = 0;
            number_of_taxis++;
        }

        else if(number_of_members[i] == 3){
            for(int t = 0 ; t < number_of_groups; t++){
                if(number_of_members[t] == 1){
                    number_of_members[i] = 0;
                    number_of_members[t] = 0;
                    number_of_taxis++;
                    break;
                }
            }
        }
        else if(number_of_members[i] == 2){
            for(int t = 0; t < number_of_groups; t++){
                if((number_of_members[t] == 2) && ( i != t)){
                    number_of_members[i] = 0;
                    number_of_members[t] = 0;
                    number_of_taxis++;
                    break;
                }

            }
        }
        //printf("%d\n", number_of_taxis);
    }

    int left_ones;
    int a,b,c,d;
    for(int i =  0; i < number_of_groups; i++){
        if(number_of_members[i] == 1){
            left_ones = 1;
            for(int t = 0;  t < number_of_groups; t++){
                if((number_of_members[t] == 1) && (i != t)){
                    left_ones++;
                    if(left_ones == 2){
                        a = t;
                    }
                    else if(left_ones == 3){
                        b = t;
                    }
                    else if(left_ones == 4){
                        c = t;
                        number_of_members[i] = 0;
                        number_of_members[a] = 0;
                        number_of_members[b] = 0;
                        number_of_members[c] = 0;
                        number_of_taxis++;
                    }
                }
                //printf("%d\n", number_of_taxis);
            }
        }
    }
    //printf("%d\n", number_of_taxis);
    left_ones = 0;
    for(int i =  0; i < number_of_groups; i++){
        if(number_of_members[i] == 2){
            for(int t = 0;  t < number_of_groups; t++){
                if(number_of_members[t] == 1){
                    left_ones++;
                    if(left_ones == 1){
                        a = t;
                    }
                    else if(left_ones == 2){
                        b = t;
                    }
                }
                if(left_ones == 2){
                    left_ones = 0;
                    number_of_members[i] = 0;
                    number_of_members[a] = 0;
                    number_of_members[b] = 0;
                    number_of_taxis++;
                }
            }
        }
    }

    //printf("%d\n", number_of_taxis);
    /*for(int i = 0; i < number_of_groups; i++){
        for(int j = 0; j < number_of_groups; j++){
            if((number_of_members[i] + number_of_members[j] <= 4) && (i != j) && (number_of_members[i] != 0) && (number_of_members[j] != 0)){
                number_of_members[i] = 0;
                number_of_members[j] = 0;
                number_of_taxis++;
            }
        }
    }*/

    //printf("%d\n", number_of_taxis);

    for(int i = 0; i < number_of_groups; i++){
        for(int j = 0; j < number_of_groups; j++){
            for(int k = 0; k < number_of_groups; k++){
                if((number_of_members[i] + number_of_members[j] + number_of_members[k] <= 4) && (i != j) && (i != k) && (j != k) && ( != 0) && (number_of_members[i] + number_of_members[j] + number_of_members[k] != 0)){
                    number_of_members[i] = 0;
                    number_of_members[j] = 0;
                    number_of_members[k] = 0;
                    number_of_taxis++;
                }
            }
        }
    }

    for(int i = 0; i < number_of_groups; i++){
        if(number_of_members[i] != 0){
            number_of_taxis++;
        }
    }
    printf("%d", number_of_taxis);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int min(int x, int y){
    if(x >= y){
        return y;
    }
    else if( x < y ){
        return x;
    }
}

int main(){
    int number_of_groups, three_people = 0, two_people = 0, one_person = 0;
    scanf("%d", &number_of_groups);
    int number_of_members[number_of_groups + 5];
    int number_of_taxis = 0;
    for(int i = 0; i < number_of_groups; i++){
        scanf("%d", &number_of_members[i]);
        if(number_of_members[i] == 4){
            number_of_taxis++;
        }
        else if(number_of_members[i] == 3){
            three_people++;
        }
        else if(number_of_members[i] == 2){
            two_people++;
        }
        else if(number_of_members[i] == 1){
            one_person++;
        }
    }
    int a = min(three_people, one_person);
    number_of_taxis = number_of_taxis + a;
    three_people = three_people - a;
    one_person = one_person - a;
    if(three_people != 0){
        number_of_taxis = number_of_taxis + three_people;
        three_people = 0;
    }
    int b = min(one_person, 2*two_people);
    if(b%2 == 1){
        number_of_taxis = number_of_taxis + b/2 + b%2;
        two_people = two_people - b/2 - b%2;
    }
    else if(b%2 == 0){
        number_of_taxis = number_of_taxis + b/2;
        two_people = two_people - b/2;
    }
    printf("%d\n", number_of_taxis);
    one_person = one_person - b;
    //two_people = two_people - b/2;
    if(two_people != 0){
        number_of_taxis = number_of_taxis + two_people/2;
        if(two_people%2 == 1){
            number_of_taxis =number_of_taxis + 1;
        }
    }
    number_of_taxis = number_of_taxis + one_person/4;
    if(one_person%4 != 0){
        number_of_taxis = number_of_taxis + 1;
    }
    printf("%d", number_of_taxis);
}


#include <bits/stdc++.h>

using namespace std;

bool check(string a, string b){
	if(a == b)return true;
	int sa = a.size(); int sb = b.size();
	if(sa == sb && sb % 2 == 0){
		string va, vb, vc, vd;
		for(int i = 0 ; i < sa / 2; i ++)va.push_back(a[i]), vc.push_back(b[i]);
		for(int i = sa / 2; i < sa; i ++)vb.push_back(a[i]), vd.push_back(b[i]);
		if((check(va, vc) && check(vb, vd)) || (check(va, vd) && check(vb, vc)))
		return true;
	}
	return false;
}

int main() {
	string a, b;
	cin >> a >> b;
	if(check(a, b))cout << "YES";
	else cout << "NO";
}


#include <bits/stdc++.h>

using namespace std;

bool check(string a, string b){
	if(a == b)return true;
	int sa = a.size(); int sb = b.size();
	int g[27];
	fill(g, g + 27, 0);
	for(int i = 0 ; i < sa; i ++)g[a[i] - 'a' + 1] ++;
	for(int i = 0; i < sb; i ++)g[b[i] - 'a' + 1] --;
	for(int i = 0 ; i < 27; i ++) if(g[i])return false;
	if(sa == sb && sb % 2 == 0){
		string va, vb, vc, vd;
		for(int i = 0 ; i < sa / 2; i ++)va.push_back(a[i]), vc.push_back(b[i]);
		for(int i = sa / 2; i < sa; i ++)vb.push_back(a[i]), vd.push_back(b[i]);
		if((check(va, vc) && check(vb, vd)) || (check(va, vd) && check(vb, vc)))
		return true;
	}
	return false;
}

int main() {
	string a, b;
	cin >> a >> b;
	if(check(a, b))cout << "YES";
	else cout << "NO";
}


/*
*
* solved by Kareem M. Mohsen
*/
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<iterator>
#include<ctype.h>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<numeric>
#include <math.h>

using namespace std;

typedef long long int      ll;
typedef vector<double>     vd;
typedef vector<string>     vs;
typedef pair <ll, ll >     ii;
typedef pair<string, ll >  si;
typedef pair<ll, string>   is;
typedef pair<char, ll >    chi;
typedef vector<ll >        vi;
typedef vector<vi>         vvi;
typedef vector< ii >       vii;
#define KareemMohsen	   int main()
#define NoSync_NoTie	   ios_base::sync_with_stdio(0); cin.tie(0);
#define x				   first
#define y                  second
#define all(v)             v.begin(),v.end()
#define sz(V)              ((ll )((V).size()))
#define pp(x)              push_back(x)
#define lop(i,n)           for(ll i=0;i<n;++i)
#define loop(i,f,l)        for(ll i=f;i<l;++i)
#define PI                 3.141592653589793
#define print(v)           lop(i, v.size()) cout<<v[i]<<" ";
#define read(v)            lop(i, (ll)v.size()) cin>>v[i];
#define INF                (1<<59)
#define CLR(v, d)          memset(v, d, sizeof(v))
double const EPS = 2.22045e-016;
unsigned long long int fact(unsigned long long int n){ if (n == 1 || n == 0)return 1; return n*fact(n - 1); }
ll  gcd(ll  a, ll  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll  lcm(ll  a, ll  b){ return ((a*b) / gcd(a, b)); }
bool comp(ll x, ll y){ return x>y; }
string int2str(ll n){ std::ostringstream stm; stm << n; return stm.str(); }
ll  str2int(string s){ istringstream ss(s); ll t; ss >> t; return t; }
ll  pw(ll  b, ll  p){ if (!p) return 1; ll  sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }
ll  sd(ll  x){ return x<10 ? x : x % 10 + sd(x / 10); }
ll  sq(ll  x){ lop(i, x)if ((ll)i*i > x) return (i - 1); return ll(1); }
bool is_integer(float k){ return std::floor(k) == k; }

ll nCr(ll n, ll r)
{
	ll res = 1;
	lop(i, r) res = res * (n - i) / (i + 1);
	return res;
}

bool eq(string s, string t){
	if (sz(s) % 2)return (s == t);
	string s1 = s.substr(0, sz(s) / 2), s2 = s.substr(sz(s) / 2, sz(s) / 2);
	string t1 = t.substr(0, sz(t) / 2), t2 = t.substr(sz(t) / 2, sz(t) / 2);
	return((eq(s1, t1) && eq(s2, t2))
		|| (eq(s1, t2) && eq(s2, t1)));
}

KareemMohsen{
	NoSync_NoTie
#ifndef ONLINE_JUDGE
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	string str1, str2; cin >> str1 >> str2;
	if (eq(str1, str2))cout << "YES"; else cout << "NO";
	return false;
}


/*
*
* solved by Kareem M. Mohsen
*/
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<iterator>
#include<ctype.h>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<numeric>
#include <math.h>

using namespace std;

typedef long long int      ll;
typedef vector<double>     vd;
typedef vector<string>     vs;
typedef pair <ll, ll >     ii;
typedef pair<string, ll >  si;
typedef pair<ll, string>   is;
typedef pair<char, ll >    chi;
typedef vector<ll >        vi;
typedef vector<vi>         vvi;
typedef vector< ii >       vii;
#define KareemMohsen	   int main()
#define NoSync_NoTie	   ios_base::sync_with_stdio(0); cin.tie(0);
#define x				   first
#define y                  second
#define all(v)             v.begin(),v.end()
#define sz(V)              ((ll )((V).size()))
#define pp(x)              push_back(x)
#define lop(i,n)           for(ll i=0;i<n;++i)
#define loop(i,f,l)        for(ll i=f;i<l;++i)
#define PI                 3.141592653589793
#define print(v)           lop(i, v.size()) cout<<v[i]<<" ";
#define read(v)            lop(i, (ll)v.size()) cin>>v[i];
#define INF                (1<<59)
#define CLR(v, d)          memset(v, d, sizeof(v))
double const EPS = 2.22045e-016;
unsigned long long int fact(unsigned long long int n){ if (n == 1 || n == 0)return 1; return n*fact(n - 1); }
ll  gcd(ll  a, ll  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll  lcm(ll  a, ll  b){ return ((a*b) / gcd(a, b)); }
bool comp(ll x, ll y){ return x>y; }
string int2str(ll n){ std::ostringstream stm; stm << n; return stm.str(); }
ll  str2int(string s){ istringstream ss(s); ll t; ss >> t; return t; }
ll  pw(ll  b, ll  p){ if (!p) return 1; ll  sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }
ll  sd(ll  x){ return x<10 ? x : x % 10 + sd(x / 10); }
ll  sq(ll  x){ lop(i, x)if ((ll)i*i > x) return (i - 1); return ll(1); }
bool is_integer(float k){ return std::floor(k) == k; }

ll nCr(ll n, ll r)
{
	ll res = 1;
	lop(i, r) res = res * (n - i) / (i + 1);
	return res;
}

char str1[200005], str2[200005];

char t1[200002], t2[200002];
bool solve(char *s1, char *s2, int len)
{
	int r = strncmp(s1, s2, len);
	if (!r) return true;
	if ((len&1)) return false;
	return (solve(s1, s2, len / 2) && solve(s1 + len / 2, s2 + len / 2, len / 2))
		|| (solve(s1 + len / 2, s2, len / 2) && solve(s1, s2 + len / 2, len / 2));
}
int main()
{
	scanf("%s%s", t1, t2);
	if (solve(t1, t2, strlen(t1)))
		puts("YES");
	else
		puts("NO");
	return 0;
}


/*
*
* solved by Kareem M. Mohsen
*/
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<iterator>
#include<ctype.h>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<numeric>
#include <math.h>

using namespace std;

typedef long long int      ll;
typedef vector<double>     vd;
typedef vector<string>     vs;
typedef pair <ll, ll >     ii;
typedef pair<string, ll >  si;
typedef pair<ll, string>   is;
typedef pair<char, ll >    chi;
typedef vector<ll >        vi;
typedef vector<vi>         vvi;
typedef vector< ii >       vii;
#define KareemMohsen	   int main()
#define NoSync_NoTie	   ios_base::sync_with_stdio(0); cin.tie(0);
#define x				   first
#define y                  second
#define all(v)             v.begin(),v.end()
#define sz(V)              ((ll )((V).size()))
#define pp(x)              push_back(x)
#define lop(i,n)           for(ll i=0;i<n;++i)
#define loop(i,f,l)        for(ll i=f;i<l;++i)
#define PI                 3.141592653589793
#define print(v)           lop(i, v.size()) cout<<v[i]<<" ";
#define read(v)            lop(i, (ll)v.size()) cin>>v[i];
#define INF                (1<<59)
#define CLR(v, d)          memset(v, d, sizeof(v))
double const EPS = 2.22045e-016;
unsigned long long int fact(unsigned long long int n){ if (n == 1 || n == 0)return 1; return n*fact(n - 1); }
ll  gcd(ll  a, ll  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll  lcm(ll  a, ll  b){ return ((a*b) / gcd(a, b)); }
bool comp(ll x, ll y){ return x>y; }
string int2str(ll n){ std::ostringstream stm; stm << n; return stm.str(); }
ll  str2int(string s){ istringstream ss(s); ll t; ss >> t; return t; }
ll  pw(ll  b, ll  p){ if (!p) return 1; ll  sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }
ll  sd(ll  x){ return x<10 ? x : x % 10 + sd(x / 10); }
ll  sq(ll  x){ lop(i, x)if ((ll)i*i > x) return (i - 1); return ll(1); }
bool is_integer(float k){ return std::floor(k) == k; }

ll nCr(ll n, ll r)
{
	ll res = 1;
	lop(i, r) res = res * (n - i) / (i + 1);
	return res;
}

bool eq(string s, string t, ll l){
	if (sz(s) % 2)return (s == t);
	if (s == t)return true;
	string s1 = s.substr(0, l / 2), s2 = s.substr(l / 2, l / 2);
	string t1 = t.substr(0, l / 2), t2 = t.substr(l / 2, l / 2);
	return((eq(s1, t1, l/2) && eq(s2, t2, l/2))
		|| (eq(s1, t2, l/2) && eq(s2, t1, l/2)));
}

KareemMohsen{
	NoSync_NoTie
#ifndef ONLINE_JUDGE
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	string str1, str2; cin >> str1 >> str2;
	if (eq(str1, str2, sz(str1)))cout << "YES"; else cout << "NO";
	return false;
}


/*
*
* solved by Kareem M. Mohsen
*/
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<iterator>
#include<ctype.h>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<numeric>
#include <math.h>

using namespace std;

typedef long long int      ll;
typedef vector<double>     vd;
typedef vector<string>     vs;
typedef pair <ll, ll >     ii;
typedef pair<string, ll >  si;
typedef pair<ll, string>   is;
typedef pair<char, ll >    chi;
typedef vector<ll >        vi;
typedef vector<vi>         vvi;
typedef vector< ii >       vii;
#define KareemMohsen	   int main()
#define NoSync_NoTie	   ios_base::sync_with_stdio(0); cin.tie(0);
#define x				   first
#define y                  second
#define all(v)             v.begin(),v.end()
#define sz(V)              ((ll )((V).size()))
#define pp(x)              push_back(x)
#define lop(i,n)           for(ll i=0;i<n;++i)
#define loop(i,f,l)        for(ll i=f;i<l;++i)
#define PI                 3.141592653589793
#define print(v)           lop(i, v.size()) cout<<v[i]<<" ";
#define read(v)            lop(i, (ll)v.size()) cin>>v[i];
#define INF                (1<<59)
#define CLR(v, d)          memset(v, d, sizeof(v))
double const EPS = 2.22045e-016;
unsigned long long int fact(unsigned long long int n){ if (n == 1 || n == 0)return 1; return n*fact(n - 1); }
ll  gcd(ll  a, ll  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll  lcm(ll  a, ll  b){ return ((a*b) / gcd(a, b)); }
bool comp(ll x, ll y){ return x>y; }
string int2str(ll n){ std::ostringstream stm; stm << n; return stm.str(); }
ll  str2int(string s){ istringstream ss(s); ll t; ss >> t; return t; }
ll  pw(ll  b, ll  p){ if (!p) return 1; ll  sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }
ll  sd(ll  x){ return x<10 ? x : x % 10 + sd(x / 10); }
ll  sq(ll  x){ lop(i, x)if ((ll)i*i > x) return (i - 1); return ll(1); }
bool is_integer(float k){ return std::floor(k) == k; }

ll nCr(ll n, ll r)
{
	ll res = 1;
	lop(i, r) res = res * (n - i) / (i + 1);
	return res;
}

char str1[200005], str2[200005];

bool eq(char* s, char* t, ll l){
	if (l % 2)return (!strncmp(s, t, l));
	if (!strncmp(s, t, l))return true;
	return((eq(s, t, l/2) && eq(s + l/2, t + l/2, l/2))
		|| (eq(s, t + l/2, l/2) && eq(s + l/2, t, l/2)));
}

KareemMohsen{
	NoSync_NoTie
#ifndef ONLINE_JUDGE
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	cin >> str1 >> str2;
	if (eq(str1, str2, strlen(str1)))cout << "YES"; else cout << "NO";
	return false;
}


/*
*
* solved by Kareem M. Mohsen
*/
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<iterator>
#include<ctype.h>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<numeric>
#include <math.h>

using namespace std;

typedef long long int      ll;
typedef vector<double>     vd;
typedef vector<string>     vs;
typedef pair <ll, ll >     ii;
typedef pair<string, ll >  si;
typedef pair<ll, string>   is;
typedef pair<char, ll >    chi;
typedef vector<ll >        vi;
typedef vector<vi>         vvi;
typedef vector< ii >       vii;
#define KareemMohsen	   int main()
#define NoSync_NoTie	   ios_base::sync_with_stdio(0); cin.tie(0);
#define x				   first
#define y                  second
#define all(v)             v.begin(),v.end()
#define sz(V)              ((ll )((V).size()))
#define pp(x)              push_back(x)
#define lop(i,n)           for(ll i=0;i<n;++i)
#define loop(i,f,l)        for(ll i=f;i<l;++i)
#define PI                 3.141592653589793
#define print(v)           lop(i, v.size()) cout<<v[i]<<" ";
#define read(v)            lop(i, (ll)v.size()) cin>>v[i];
#define INF                (1<<59)
#define CLR(v, d)          memset(v, d, sizeof(v))
double const EPS = 2.22045e-016;
unsigned long long int fact(unsigned long long int n){ if (n == 1 || n == 0)return 1; return n*fact(n - 1); }
ll  gcd(ll  a, ll  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll  lcm(ll  a, ll  b){ return ((a*b) / gcd(a, b)); }
bool comp(ll x, ll y){ return x>y; }
string int2str(ll n){ std::ostringstream stm; stm << n; return stm.str(); }
ll  str2int(string s){ istringstream ss(s); ll t; ss >> t; return t; }
ll  pw(ll  b, ll  p){ if (!p) return 1; ll  sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }
ll  sd(ll  x){ return x<10 ? x : x % 10 + sd(x / 10); }
ll  sq(ll  x){ lop(i, x)if ((ll)i*i > x) return (i - 1); return ll(1); }
bool is_integer(float k){ return std::floor(k) == k; }

ll nCr(ll n, ll r)
{
	ll res = 1;
	lop(i, r) res = res * (n - i) / (i + 1);
	return res;
}

bool eq(string s, string t){
	if (sz(s) % 2)return (s == t);
	if (s == t)return true;
	string s1 = s.substr(0, sz(s) / 2), s2 = s.substr(sz(s) / 2, sz(s) / 2);
	string t1 = t.substr(0, sz(t) / 2), t2 = t.substr(sz(t) / 2, sz(t) / 2);
	return((eq(s1, t1) && eq(s2, t2))
		|| (eq(s1, t2) && eq(s2, t1)));
}

KareemMohsen{
	NoSync_NoTie
#ifndef ONLINE_JUDGE
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	string str1, str2; cin >> str1 >> str2;
	if (eq(str1, str2))cout << "YES"; else cout << "NO";
	return false;
}


/*
*
* solved by Kareem M. Mohsen
*/
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<iterator>
#include<ctype.h>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<numeric>
#include <math.h>

using namespace std;

typedef long long int      ll;
typedef vector<double>     vd;
typedef vector<string>     vs;
typedef pair <ll, ll >     ii;
typedef pair<string, ll >  si;
typedef pair<ll, string>   is;
typedef pair<char, ll >    chi;
typedef vector<ll >        vi;
typedef vector<vi>         vvi;
typedef vector< ii >       vii;
#define KareemMohsen	   int main()
#define NoSync_NoTie	   ios_base::sync_with_stdio(0); cin.tie(0);
#define x				   first
#define y                  second
#define all(v)             v.begin(),v.end()
#define sz(V)              ((ll )((V).size()))
#define pp(x)              push_back(x)
#define lop(i,n)           for(ll i=0;i<n;++i)
#define loop(i,f,l)        for(ll i=f;i<l;++i)
#define PI                 3.141592653589793
#define print(v)           lop(i, v.size()) cout<<v[i]<<" ";
#define read(v)            lop(i, (ll)v.size()) cin>>v[i];
#define INF                (1<<59)
#define CLR(v, d)          memset(v, d, sizeof(v))
double const EPS = 2.22045e-016;
unsigned long long int fact(unsigned long long int n){ if (n == 1 || n == 0)return 1; return n*fact(n - 1); }
ll  gcd(ll  a, ll  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll  lcm(ll  a, ll  b){ return ((a*b) / gcd(a, b)); }
bool comp(ll x, ll y){ return x>y; }
string int2str(ll n){ std::ostringstream stm; stm << n; return stm.str(); }
ll  str2int(string s){ istringstream ss(s); ll t; ss >> t; return t; }
ll  pw(ll  b, ll  p){ if (!p) return 1; ll  sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }
ll  sd(ll  x){ return x<10 ? x : x % 10 + sd(x / 10); }
ll  sq(ll  x){ lop(i, x)if ((ll)i*i > x) return (i - 1); return ll(1); }
bool is_integer(float k){ return std::floor(k) == k; }

ll nCr(ll n, ll r)
{
	ll res = 1;
	lop(i, r) res = res * (n - i) / (i + 1);
	return res;
}

char str1[200005], str2[200005];

bool eq(char* s, char* t, int l){
	int x = strncmp(s, t, l);
	if (!x) return true;
	if (l&1) return false;
	return (eq(s, t, l / 2) && eq(s + l / 2, t + l / 2, l / 2))
		|| (eq(s + l / 2, t, l / 2) && eq(s, t + l / 2, l / 2));
}

KareemMohsen{
	NoSync_NoTie
#ifndef ONLINE_JUDGE
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	scanf("%s%s", str1, str2);
	if (eq(str1, str2, strlen(str1)))puts("YES");
	else puts("NO");
	return false;
}


/*
*
* solved by Kareem M. Mohsen
*/
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<iterator>
#include<ctype.h>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<numeric>
#include <math.h>

using namespace std;

typedef long long int      ll;
typedef vector<double>     vd;
typedef vector<string>     vs;
typedef pair <ll, ll >     ii;
typedef pair<string, ll >  si;
typedef pair<ll, string>   is;
typedef pair<char, ll >    chi;
typedef vector<ll >        vi;
typedef vector<vi>         vvi;
typedef vector< ii >       vii;
#define KareemMohsen	   int main()
#define NoSync_NoTie	   ios_base::sync_with_stdio(0); cin.tie(0);
#define x				   first
#define y                  second
#define all(v)             v.begin(),v.end()
#define sz(V)              ((ll )((V).size()))
#define pp(x)              push_back(x)
#define lop(i,n)           for(ll i=0;i<n;++i)
#define loop(i,f,l)        for(ll i=f;i<l;++i)
#define PI                 3.141592653589793
#define print(v)           lop(i, v.size()) cout<<v[i]<<" ";
#define read(v)            lop(i, (ll)v.size()) cin>>v[i];
#define INF                (1<<59)
#define CLR(v, d)          memset(v, d, sizeof(v))
double const EPS = 2.22045e-016;
unsigned long long int fact(unsigned long long int n){ if (n == 1 || n == 0)return 1; return n*fact(n - 1); }
ll  gcd(ll  a, ll  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll  lcm(ll  a, ll  b){ return ((a*b) / gcd(a, b)); }
bool comp(ll x, ll y){ return x>y; }
string int2str(ll n){ std::ostringstream stm; stm << n; return stm.str(); }
ll  str2int(string s){ istringstream ss(s); ll t; ss >> t; return t; }
ll  pw(ll  b, ll  p){ if (!p) return 1; ll  sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }
ll  sd(ll  x){ return x<10 ? x : x % 10 + sd(x / 10); }
ll  sq(ll  x){ lop(i, x)if ((ll)i*i > x) return (i - 1); return ll(1); }
bool is_integer(float k){ return std::floor(k) == k; }

ll nCr(ll n, ll r)
{
	ll res = 1;
	lop(i, r) res = res * (n - i) / (i + 1);
	return res;
}

bool eq(string s, string t){
	if (sz(s) % 2)return (s == t);
	return((eq(s.substr(0, sz(s) / 2), t.substr(0, sz(t) / 2)) && eq(s.substr(sz(s) / 2, sz(s) / 2), t.substr(sz(t) / 2, sz(t) / 2)))
		|| (eq(s.substr(0, sz(s) / 2), t.substr(sz(t) / 2, sz(t) / 2)) && eq(s.substr(sz(s) / 2, sz(s) / 2), t.substr(0, sz(t) / 2))));
}

KareemMohsen{
	NoSync_NoTie
#ifndef ONLINE_JUDGE
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	string str1, str2; cin >> str1 >> str2;
	if (eq(str1, str2))cout << "YES"; else cout << "NO";
	return false;
}


/*
*
* solved by Kareem M. Mohsen
*/
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<iterator>
#include<ctype.h>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<numeric>
#include <math.h>

using namespace std;

typedef long long int      ll;
typedef vector<double>     vd;
typedef vector<string>     vs;
typedef pair <ll, ll >     ii;
typedef pair<string, ll >  si;
typedef pair<ll, string>   is;
typedef pair<char, ll >    chi;
typedef vector<ll >        vi;
typedef vector<vi>         vvi;
typedef vector< ii >       vii;
#define KareemMohsen	   int main()
#define NoSync_NoTie	   ios_base::sync_with_stdio(0); cin.tie(0);
#define x				   first
#define y                  second
#define all(v)             v.begin(),v.end()
#define sz(V)              ((ll )((V).size()))
#define pp(x)              push_back(x)
#define lop(i,n)           for(ll i=0;i<n;++i)
#define loop(i,f,l)        for(ll i=f;i<l;++i)
#define PI                 3.141592653589793
#define print(v)           lop(i, v.size()) cout<<v[i]<<" ";
#define read(v)            lop(i, (ll)v.size()) cin>>v[i];
#define INF                (1<<59)
#define CLR(v, d)          memset(v, d, sizeof(v))
double const EPS = 2.22045e-016;
unsigned long long int fact(unsigned long long int n){ if (n == 1 || n == 0)return 1; return n*fact(n - 1); }
ll  gcd(ll  a, ll  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll  lcm(ll  a, ll  b){ return ((a*b) / gcd(a, b)); }
bool comp(ll x, ll y){ return x>y; }
string int2str(ll n){ std::ostringstream stm; stm << n; return stm.str(); }
ll  str2int(string s){ istringstream ss(s); ll t; ss >> t; return t; }
ll  pw(ll  b, ll  p){ if (!p) return 1; ll  sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }
ll  sd(ll  x){ return x<10 ? x : x % 10 + sd(x / 10); }
ll  sq(ll  x){ lop(i, x)if ((ll)i*i > x) return (i - 1); return ll(1); }
bool is_integer(float k){ return std::floor(k) == k; }

ll nCr(ll n, ll r)
{
	ll res = 1;
	lop(i, r) res = res * (n - i) / (i + 1);
	return res;
}

char str1[200005], str2[200005];

bool eq(char* s, char* t, ll l){
	int x = strncmp(s, t, l);
	if (!x) return true;
	if (l % 2) return false;
	return((eq(s, t, l / 2) && eq(s + l / 2, t + l / 2, l / 2))
		|| (eq(s, t + l/2, l/2) && eq(s + l/2, t, l/2)));
}

KareemMohsen{
	NoSync_NoTie
#ifndef ONLINE_JUDGE
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	cin >> str1 >> str2;
	if (eq(str1, str2, strlen(str1)))cout << "YES"; else cout << "NO";
	return false;
}


/*
*
* solved by Kareem M. Mohsen
*/
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<iterator>
#include<ctype.h>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<numeric>
#include <math.h>

using namespace std;

typedef long long int      ll;
typedef vector<double>     vd;
typedef vector<string>     vs;
typedef pair <ll, ll >     ii;
typedef pair<string, ll >  si;
typedef pair<ll, string>   is;
typedef pair<char, ll >    chi;
typedef vector<ll >        vi;
typedef vector<vi>         vvi;
typedef vector< ii >       vii;
#define KareemMohsen	   int main()
#define NoSync_NoTie	   ios_base::sync_with_stdio(0); cin.tie(0);
#define x				   first
#define y                  second
#define all(v)             v.begin(),v.end()
#define sz(V)              ((ll )((V).size()))
#define pp(x)              push_back(x)
#define lop(i,n)           for(ll i=0;i<n;++i)
#define loop(i,f,l)        for(ll i=f;i<l;++i)
#define PI                 3.141592653589793
#define print(v)           lop(i, v.size()) cout<<v[i]<<" ";
#define read(v)            lop(i, (ll)v.size()) cin>>v[i];
#define INF                (1<<59)
#define CLR(v, d)          memset(v, d, sizeof(v))
double const EPS = 2.22045e-016;
unsigned long long int fact(unsigned long long int n){ if (n == 1 || n == 0)return 1; return n*fact(n - 1); }
ll  gcd(ll  a, ll  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll  lcm(ll  a, ll  b){ return ((a*b) / gcd(a, b)); }
bool comp(ll x, ll y){ return x>y; }
string int2str(ll n){ std::ostringstream stm; stm << n; return stm.str(); }
ll  str2int(string s){ istringstream ss(s); ll t; ss >> t; return t; }
ll  pw(ll  b, ll  p){ if (!p) return 1; ll  sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }
ll  sd(ll  x){ return x<10 ? x : x % 10 + sd(x / 10); }
ll  sq(ll  x){ lop(i, x)if ((ll)i*i > x) return (i - 1); return ll(1); }
bool is_integer(float k){ return std::floor(k) == k; }

ll nCr(ll n, ll r)
{
	ll res = 1;
	lop(i, r) res = res * (n - i) / (i + 1);
	return res;
}

char str1[200005], str2[200005];

bool eq(char* s, char* t, int l){
	int x = strncmp(s, t, l);
	if (!x) return true;
	if (l&1) return false;
	return((eq(s, t, l / 2) && eq(s + l / 2, t + l / 2, l / 2))
		|| (eq(s, t + l/2, l/2) && eq(s + l/2, t, l/2)));
}

KareemMohsen{
	NoSync_NoTie
#ifndef ONLINE_JUDGE
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	cin >> str1 >> str2;
	if (eq(str1, str2, strlen(str1)))cout << "YES"; else cout << "NO";
	return false;
}


/*
*
* solved by Kareem M. Mohsen
*/
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<iterator>
#include<ctype.h>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<numeric>
#include <math.h>

using namespace std;

typedef long long int      ll;
typedef vector<double>     vd;
typedef vector<string>     vs;
typedef pair <ll, ll >     ii;
typedef pair<string, ll >  si;
typedef pair<ll, string>   is;
typedef pair<char, ll >    chi;
typedef vector<ll >        vi;
typedef vector<vi>         vvi;
typedef vector< ii >       vii;
#define KareemMohsen	   int main()
#define NoSync_NoTie	   ios_base::sync_with_stdio(0); cin.tie(0);
#define x				   first
#define y                  second
#define all(v)             v.begin(),v.end()
#define sz(V)              ((ll )((V).size()))
#define pp(x)              push_back(x)
#define lop(i,n)           for(ll i=0;i<n;++i)
#define loop(i,f,l)        for(ll i=f;i<l;++i)
#define PI                 3.141592653589793
#define print(v)           lop(i, v.size()) cout<<v[i]<<" ";
#define read(v)            lop(i, (ll)v.size()) cin>>v[i];
#define INF                (1<<59)
#define CLR(v, d)          memset(v, d, sizeof(v))
double const EPS = 2.22045e-016;
unsigned long long int fact(unsigned long long int n){ if (n == 1 || n == 0)return 1; return n*fact(n - 1); }
ll  gcd(ll  a, ll  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll  lcm(ll  a, ll  b){ return ((a*b) / gcd(a, b)); }
bool comp(ll x, ll y){ return x>y; }
string int2str(ll n){ std::ostringstream stm; stm << n; return stm.str(); }
ll  str2int(string s){ istringstream ss(s); ll t; ss >> t; return t; }
ll  pw(ll  b, ll  p){ if (!p) return 1; ll  sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }
ll  sd(ll  x){ return x<10 ? x : x % 10 + sd(x / 10); }
ll  sq(ll  x){ lop(i, x)if ((ll)i*i > x) return (i - 1); return ll(1); }
bool is_integer(float k){ return std::floor(k) == k; }

ll nCr(ll n, ll r)
{
	ll res = 1;
	lop(i, r) res = res * (n - i) / (i + 1);
	return res;
}

char str1[200005], str2[200005];

bool eq(char* s, char* t, ll l){
	int x = strncmp(s, t, l);
	if (!x) return true;
	if (l&1) return false;
	return((eq(s, t, l / 2) && eq(s + l / 2, t + l / 2, l / 2))
		|| (eq(s, t + l/2, l/2) && eq(s + l/2, t, l/2)));
}

KareemMohsen{
	NoSync_NoTie
#ifndef ONLINE_JUDGE
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	scanf("%s%s", str1, str2);
	if (eq(str1, str2, strlen(str1)))cout << "YES"; else cout << "NO";
	return false;
}


/*
*
* solved by Kareem M. Mohsen
*/
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<iterator>
#include<ctype.h>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<numeric>
#include <math.h>

using namespace std;

typedef long long int      ll;
typedef vector<double>     vd;
typedef vector<string>     vs;
typedef pair <ll, ll >     ii;
typedef pair<string, ll >  si;
typedef pair<ll, string>   is;
typedef pair<char, ll >    chi;
typedef vector<ll >        vi;
typedef vector<vi>         vvi;
typedef vector< ii >       vii;
#define KareemMohsen	   int main()
#define NoSync_NoTie	   ios_base::sync_with_stdio(0); cin.tie(0);
#define x				   first
#define y                  second
#define all(v)             v.begin(),v.end()
#define sz(V)              ((ll )((V).size()))
#define pp(x)              push_back(x)
#define lop(i,n)           for(ll i=0;i<n;++i)
#define loop(i,f,l)        for(ll i=f;i<l;++i)
#define PI                 3.141592653589793
#define print(v)           lop(i, v.size()) cout<<v[i]<<" ";
#define read(v)            lop(i, (ll)v.size()) cin>>v[i];
#define INF                (1<<59)
#define CLR(v, d)          memset(v, d, sizeof(v))
double const EPS = 2.22045e-016;
unsigned long long int fact(unsigned long long int n){ if (n == 1 || n == 0)return 1; return n*fact(n - 1); }
ll  gcd(ll  a, ll  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll  lcm(ll  a, ll  b){ return ((a*b) / gcd(a, b)); }
bool comp(ll x, ll y){ return x>y; }
string int2str(ll n){ std::ostringstream stm; stm << n; return stm.str(); }
ll  str2int(string s){ istringstream ss(s); ll t; ss >> t; return t; }
ll  pw(ll  b, ll  p){ if (!p) return 1; ll  sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }
ll  sd(ll  x){ return x<10 ? x : x % 10 + sd(x / 10); }
ll  sq(ll  x){ lop(i, x)if ((ll)i*i > x) return (i - 1); return ll(1); }
bool is_integer(float k){ return std::floor(k) == k; }

ll nCr(ll n, ll r)
{
	ll res = 1;
	lop(i, r) res = res * (n - i) / (i + 1);
	return res;
}

char str1[200005], str2[200005];

bool eq(char* s, char* t, int l){
	int x = strncmp(s, t, l);
	if (!x) return true;
	if (l&1) return false;
	return((eq(s, t, l / 2) && eq(s + l / 2, t + l / 2, l / 2))
		|| (eq(s, t + l/2, l/2) && eq(s + l/2, t, l/2)));
}

KareemMohsen{
	scanf("%s%s", str1, str2);
	if (eq(str1, str2, strlen(str1)))puts("YES");
	else puts("NO");
	return false;
}


/*
*
* solved by Kareem M. Mohsen
*/
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<iterator>
#include<ctype.h>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<numeric>
#include <math.h>

using namespace std;

typedef long long int      ll;
typedef vector<double>     vd;
typedef vector<string>     vs;
typedef pair <ll, ll >     ii;
typedef pair<string, ll >  si;
typedef pair<ll, string>   is;
typedef pair<char, ll >    chi;
typedef vector<ll >        vi;
typedef vector<vi>         vvi;
typedef vector< ii >       vii;
#define KareemMohsen	   int main()
#define NoSync_NoTie	   ios_base::sync_with_stdio(0); cin.tie(0);
#define x				   first
#define y                  second
#define all(v)             v.begin(),v.end()
#define sz(V)              ((ll )((V).size()))
#define pp(x)              push_back(x)
#define lop(i,n)           for(ll i=0;i<n;++i)
#define loop(i,f,l)        for(ll i=f;i<l;++i)
#define PI                 3.141592653589793
#define print(v)           lop(i, v.size()) cout<<v[i]<<" ";
#define read(v)            lop(i, (ll)v.size()) cin>>v[i];
#define INF                (1<<59)
#define CLR(v, d)          memset(v, d, sizeof(v))
double const EPS = 2.22045e-016;
unsigned long long int fact(unsigned long long int n){ if (n == 1 || n == 0)return 1; return n*fact(n - 1); }
ll  gcd(ll  a, ll  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll  lcm(ll  a, ll  b){ return ((a*b) / gcd(a, b)); }
bool comp(ll x, ll y){ return x>y; }
string int2str(ll n){ std::ostringstream stm; stm << n; return stm.str(); }
ll  str2int(string s){ istringstream ss(s); ll t; ss >> t; return t; }
ll  pw(ll  b, ll  p){ if (!p) return 1; ll  sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }
ll  sd(ll  x){ return x<10 ? x : x % 10 + sd(x / 10); }
ll  sq(ll  x){ lop(i, x)if ((ll)i*i > x) return (i - 1); return ll(1); }
bool is_integer(float k){ return std::floor(k) == k; }

ll nCr(ll n, ll r)
{
	ll res = 1;
	lop(i, r) res = res * (n - i) / (i + 1);
	return res;
}

char str1[200005], str2[200005];

bool eq(char* s, char* t, ll l){
	if (l % 2)return (strncmp(s, t, l));
	if (strncmp(s, t, l))return true;
	return((eq(s, t, l/2) && eq(s + l/2, t + l/2, l/2))
		|| (eq(s, t + l/2, l/2) && eq(s + l/2, t, l/2)));
}

KareemMohsen{
	NoSync_NoTie
#ifndef ONLINE_JUDGE
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	cin >> str1 >> str2;
	if (eq(str1, str2, strlen(str1)))cout << "YES"; else cout << "NO";
	return false;
}


/*
*
* solved by Kareem M. Mohsen
*/
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<iterator>
#include<ctype.h>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<numeric>
#include <math.h>

using namespace std;

typedef long long int      ll;
typedef vector<double>     vd;
typedef vector<string>     vs;
typedef pair <ll, ll >     ii;
typedef pair<string, ll >  si;
typedef pair<ll, string>   is;
typedef pair<char, ll >    chi;
typedef vector<ll >        vi;
typedef vector<vi>         vvi;
typedef vector< ii >       vii;
#define KareemMohsen	   int main()
#define NoSync_NoTie	   ios_base::sync_with_stdio(0); cin.tie(0);
#define x				   first
#define y                  second
#define all(v)             v.begin(),v.end()
#define sz(V)              ((ll )((V).size()))
#define pp(x)              push_back(x)
#define lop(i,n)           for(ll i=0;i<n;++i)
#define loop(i,f,l)        for(ll i=f;i<l;++i)
#define PI                 3.141592653589793
#define print(v)           lop(i, v.size()) cout<<v[i]<<" ";
#define read(v)            lop(i, (ll)v.size()) cin>>v[i];
#define INF                (1<<59)
#define CLR(v, d)          memset(v, d, sizeof(v))
double const EPS = 2.22045e-016;
unsigned long long int fact(unsigned long long int n){ if (n == 1 || n == 0)return 1; return n*fact(n - 1); }
ll  gcd(ll  a, ll  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll  lcm(ll  a, ll  b){ return ((a*b) / gcd(a, b)); }
bool comp(ll x, ll y){ return x>y; }
string int2str(ll n){ std::ostringstream stm; stm << n; return stm.str(); }
ll  str2int(string s){ istringstream ss(s); ll t; ss >> t; return t; }
ll  pw(ll  b, ll  p){ if (!p) return 1; ll  sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }
ll  sd(ll  x){ return x<10 ? x : x % 10 + sd(x / 10); }
ll  sq(ll  x){ lop(i, x)if ((ll)i*i > x) return (i - 1); return ll(1); }
bool is_integer(float k){ return std::floor(k) == k; }

ll nCr(ll n, ll r)
{
	ll res = 1;
	lop(i, r) res = res * (n - i) / (i + 1);
	return res;
}

char str1[200005], str2[200005];

bool eq(char* s, char* t, ll l){
	int x = strncmp(s, t, l);
	if (l % 2)return (!x);
	if (!x)return true;
	return((eq(s, t, l/2) && eq(s + l/2, t + l/2, l/2))
		|| (eq(s, t + l/2, l/2) && eq(s + l/2, t, l/2)));
}

KareemMohsen{
	NoSync_NoTie
#ifndef ONLINE_JUDGE
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	cin >> str1 >> str2;
	if (eq(str1, str2, strlen(str1)))cout << "YES"; else cout << "NO";
	return false;
}


/*
*
* solved by Kareem M. Mohsen
*/
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<iterator>
#include<ctype.h>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<numeric>
#include <math.h>

using namespace std;

typedef long long int      ll;
typedef vector<double>     vd;
typedef vector<string>     vs;
typedef pair <ll, ll >     ii;
typedef pair<string, ll >  si;
typedef pair<ll, string>   is;
typedef pair<char, ll >    chi;
typedef vector<ll >        vi;
typedef vector<vi>         vvi;
typedef vector< ii >       vii;
#define KareemMohsen	   int main()
#define NoSync_NoTie	   ios_base::sync_with_stdio(0); cin.tie(0);
#define x				   first
#define y                  second
#define all(v)             v.begin(),v.end()
#define sz(V)              ((ll )((V).size()))
#define pp(x)              push_back(x)
#define lop(i,n)           for(ll i=0;i<n;++i)
#define loop(i,f,l)        for(ll i=f;i<l;++i)
#define PI                 3.141592653589793
#define print(v)           lop(i, v.size()) cout<<v[i]<<" ";
#define read(v)            lop(i, (ll)v.size()) cin>>v[i];
#define INF                (1<<59)
#define CLR(v, d)          memset(v, d, sizeof(v))
double const EPS = 2.22045e-016;
unsigned long long int fact(unsigned long long int n){ if (n == 1 || n == 0)return 1; return n*fact(n - 1); }
ll  gcd(ll  a, ll  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll  lcm(ll  a, ll  b){ return ((a*b) / gcd(a, b)); }
bool comp(ll x, ll y){ return x>y; }
string int2str(ll n){ std::ostringstream stm; stm << n; return stm.str(); }
ll  str2int(string s){ istringstream ss(s); ll t; ss >> t; return t; }
ll  pw(ll  b, ll  p){ if (!p) return 1; ll  sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }
ll  sd(ll  x){ return x<10 ? x : x % 10 + sd(x / 10); }
ll  sq(ll  x){ lop(i, x)if ((ll)i*i > x) return (i - 1); return ll(1); }
bool is_integer(float k){ return std::floor(k) == k; }

ll nCr(ll n, ll r)
{
	ll res = 1;
	lop(i, r) res = res * (n - i) / (i + 1);
	return res;
}

char str1[200005], str2[200005];

bool eq(char* s, char* t, ll l){
	if (l % 2)return (strncmp(s, t, l));
	if (!strncmp(s, t, l))return true;
	return((eq(s, t, l/2) && eq(s + l/2, t + l/2, l/2))
		|| (eq(s, t + l/2, l/2) && eq(s + l/2, t, l/2)));
}

KareemMohsen{
	NoSync_NoTie
#ifndef ONLINE_JUDGE
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	cin >> str1 >> str2;
	if (eq(str1, str2, strlen(str1)))cout << "YES"; else cout << "NO";
	return false;
}


#include <bits/stdc++.h>

using namespace std;

int a,b,c,d[30],e[30];
string s , q;

int bberry(string x , string y)
{
   if(x == y)
       return 1;
   if(x.size() % 2 == 1)
       return 0;

   for(int i = 0 ; i < 26 ; i++)
      D[i] = 0 , e[i] = 0;

   for(int i = 0 ; i < x.size() ; i++)
      d[x[i]-'a']++ , e[y[i]-'a']++;

   a = x.size() / 2;

   for(int i = 0 ; i < 26 ; i++)
      if(d[i] != e[i]) return 0;

   if(bberry(x.substr(0 , a) , y.substr(0 , a)) && bberry(x.substr(a , x.size()-1) , y.substr(a , y.size()-1)))
      return 1;

   if(bberry(x.substr(0 , a) , y.substr(a , y.size()-1)) && bberry(y.substr(0 , a) , x.substr(a , x.size()-1)))
      return 1;
   return 0;
}

int main()
{

   cin>>s>>q;

   if(bberry(s , q)) cout << "YES";
   else              cout << "NO";

   return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a,b,c,d[30],e[30];
string s , q;

int bberry(string x , string y)
{
   if(x == y)
       return 1;
   if(x.size() % 2 == 1)
       return 0;

   for(int i = 0 ; i < 26 ; i++)
      d[i] = 0 , e[i] = 0;

   for(int i = 0 ; i < x.size() ; i++)
      d[x[i]-'a']++ , e[y[i]-'a']++;

   a = x.size() / 2;

   for(int i = 0 ; i < 26 ; i++)
      if(d[i] != e[i]) return 0;

   if(bberry(x.substr(0 , a) , y.substr(0 , a)) && bberry(x.substr(a , x.size()-1) , y.substr(a , y.size()-1)))
      return 1;

   if(bberry(x.substr(0 , a) , y.substr(a , y.size()-1)) && bberry(y.substr(0 , a) , x.substr(a , x.size()-1)))
      return 1;
   return 0;
}

int main()
{

   cin>>s>>q;

   if(bberry(s , q)) cout << "YES";
   else              cout << "NO";

   return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a,b,c,d[30],e[30];
string s , q;
// made on blackberry not on computer
int bberry(string x , string y)
{
   if(x.size() != y.size())
       return 0;
   if(x.size() % 2 == 1)
       return 0;

   for(int i = 0 ; i < 26 ; i++)
      D[i] = 0 , e[i] = 0;

   for(int i = 0 ; i < x.size() ; i++)
      d[x[i]-'a']++ , e[y[i]-'a']++;

   a = x.size() / 2;

   for(int i = 0 ; i < 26 ; i++)
      if(d[i] != e[i]) return 0;

   if(bberry(x.substr(0 , a) , x.substr(a , x.size()-1)) && bberry(y.substr(0 , a) , y.substr(a , y.size()-1)))
      return 1;

   if(bberry(x.substr(0 , a) , y.substr(a , y.size()-1)) && bberry(y.substr(0 , a) , x.substr(a , x.size()-1)))
      return 1;

}

int main()
{

   cin>>s>>q;

   if(bberry(s , q)) cout << "YES";
   else              cout << "NO";

   return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a,b,c,d[30],e[30];
string s , q;

int bberry(string x , string y)
{
   if(x == y)
       return 1;
   if(x.size() % 2 == 1)
       return 0;

   for(int i = 0 ; i < 26 ; i++)
      D[i] = 0 , e[i] = 0;

   for(int i = 0 ; i < x.size() ; i++)
      d[x[i]-'a']++ , e[y[i]-'a']++;

   a = x.size() / 2;

   for(int i = 0 ; i < 26 ; i++){
      if(d[i] != e[i]) return 0;
      d[i] = 0 , e[i] = 0;
   }
   if(bberry(x.substr(0 , a) , x.substr(a , x.size()-1)) && bberry(y.substr(0 , a) , y.substr(a , y.size()-1)))
      return 1;

   if(bberry(x.substr(0 , a) , y.substr(a , y.size()-1)) && bberry(y.substr(0 , a) , x.substr(a , x.size()-1)))
      return 1;
   return 0;
}

int main()
{

   cin>>s>>q;

   if(bberry(s , q)) cout << "YES";
   else              cout << "NO";

   return 0;
}


#include <bits/stdc++.h>

using namespace std;

int b,c,d[30],e[30] , m, n;
string s , q;

int bberry(string x , string y)
{
   if(x == y)
       return 1;
   if(x.size() % 2 == 1)
       return 0;

   for(int i = 0 ; i < 26 ; i++)
      d[i] = 0 , e[i] = 0;

   for(int i = 0 ; i < x.size() ; i++)
      d[x[i]-'a']++ , e[y[i]-'a']++;

   int a = x.size() / 2;

   for(int i = 0 ; i < 26 ; i++)
      if(d[i] != e[i]) return 0;

   if(bberry(x.substr(0 , a) , y.substr(0 , a)) && bberry(x.substr(a , x.size()-1) , y.substr(a , y.size()-1)))
      return 1;

   if(bberry(x.substr(0 , a) , y.substr(a , y.size()-1)) && bberry(x.substr(a , x.size()-1) , y.substr(0 , a)))
      return 1;
   return 0;
}

int main()
{

   cin>>s>>q;

   if(bberry(s , q)) cout << "YES";
   else              cout << "NO";

   return 0;
}


#include <bits/stdc++.h>

using namespace std;

int b,c,d[30],e[30];
string s , q;

int bberry(string x , string y)
{
   if(x == y)
       return 1;
   if(x.size() % 2 == 1)
       return 0;

   for(int i = 0 ; i < 26 ; i++)
      d[i] = 0 , e[i] = 0;

   for(int i = 0 ; i < x.size() ; i++)
      d[x[i]-'a']++ , e[y[i]-'a']++;

   int a = x.size() / 2;

   for(int i = 0 ; i < 26 ; i++)
      if(d[i] != e[i]) return 0;

   if(bberry(x.substr(0 , a) , y.substr(0 , a)) && bberry(x.substr(a , x.size()-1) , y.substr(a , y.size()-1)))
      return 1;

   if(bberry(x.substr(0 , a) , y.substr(a , y.size()-1)) && bberry(x.substr(a , x.size()-1) , y.substr(0 , a)))
      return 1;
}

int main()
{

   cin>>s>>q;

   if(bberry(s , q)) cout << "YES";
   else              cout << "NO";

   return 0;
}


#include <bits/stdc++.h>

using namespace std;

int b,c,d[30],e[30];
string s , q;

int bberry(string x , string y)
{
   if(x == y)
       return 1;
   if(x.size() % 2 == 1)
       return 0;

   for(int i = 0 ; i < 26 ; i++)
      d[i] = 0 , e[i] = 0;

   for(int i = 0 ; i < x.size() ; i++)
      d[x[i]-'a']++ , e[y[i]-'a']++;

   int a = x.size() / 2;

   for(int i = 0 ; i < 26 ; i++)
      if(d[i] != e[i]) return 0;

   if(bberry(x.substr(0 , a) , y.substr(0 , a)) && bberry(x.substr(a , x.size()-1) , y.substr(a , y.size()-1)))
      return 1;

   if(bberry(x.substr(0 , a) , y.substr(a , y.size()-1)) && bberry(x.substr(a , x.size()-1) , y.substr(0 , a)))
      return 1;
   return 0;
}

int main()
{

   cin>>s>>q;

   if(bberry(s , q)) cout << "YES";
   else              cout << "NO";

   return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a,b,c,d[30],e[30];
string s , q;

int bberry(string x , string y)
{
   if(x == y)
       return 1;
   if(x.size() % 2 == 1)
       return 0;

   for(int i = 0 ; i < 26 ; i++)
      d[i] = 0 , e[i] = 0;

   for(int i = 0 ; i < x.size() ; i++)
      d[x[i]-'a']++ , e[y[i]-'a']++;

   a = x.size() / 2;

   for(int i = 0 ; i < 26 ; i++)
      if(d[i] != e[i]) return 0;

   if(bberry(x.substr(0 , a) , y.substr(0 , a)) && bberry(x.substr(a , x.size()-1) , y.substr(a , y.size()-1)))
      return 1;

   if(bberry(x.substr(0 , a) , y.substr(a , y.size()-1)) && bberry(x.substr(a , x.size()-1) , y.substr(0 , a)))
      return 1;
   return 0;
}

int main()
{

   cin>>s>>q;

   if(bberry(s , q)) cout << "YES";
   else              cout << "NO";

   return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a,b,c,d[30],e[30];
string s , q;
// made on blackberry not on computer
int bberry(string x , string y)
{
   if(x.size() != y.size())
       return 0;
   if(x.size() % 2 == 1)
       return 0;

   for(int i = 0 ; i < 26 ; i++)
      d[i] = 0 , e[i] = 0;

   for(int i = 0 ; i < x.size() ; i++)
      d[x[i]-'a']++ , e[y[i]-'a']++;

   a = x.size() / 2;

   for(int i = 0 ; i < 26 ; i++)
      if(d[i] != e[i]) return 0;

   if(bberry(x.substr(0 , a) , x.substr(a , x.size()-1)) && bberry(y.substr(0 , a) , y.substr(a , y.size()-1)))
      return 1;

   if(bberry(x.substr(0 , a) , y.substr(a , y.size()-1)) && bberry(y.substr(0 , a) , x.substr(a , x.size()-1)))
      return 1;

}

int main()
{

   cin>>s>>q;

   if(bberry(s , q)) cout << "YES";
   else              cout << "NO";

   return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a,b,c,d[30],e[30];
string s , q;
// made on blackberry not on computer
int bberry(string x , string y)
{
   if(x == y)
       return 1;
   if(x.size() % 2 == 1)
       return 0;

   for(int i = 0 ; i < 26 ; i++)
      d[i] = 0 , e[i] = 0;

   for(int i = 0 ; i < x.size() ; i++)
      d[x[i]-'a']++ , e[y[i]-'a']++;

   a = x.size() / 2;

   for(int i = 0 ; i < 26 ; i++)
      if(d[i] != e[i]) return 0;

   if(bberry(x.substr(0 , a) , x.substr(a , x.size()-1)) && bberry(y.substr(0 , a) , y.substr(a , y.size()-1)))
      return 1;

   if(bberry(x.substr(0 , a) , y.substr(a , y.size()-1)) && bberry(y.substr(0 , a) , x.substr(a , x.size()-1)))
      return 1;
   return 0;
}

int main()
{

   cin>>s>>q;

   if(bberry(s , q)) cout << "YES";
   else              cout << "NO";

   return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a,b,c,d[30],e[30];
string s , q;

int bberry(string x , string y)
{
   if(x == y)
       return 1;
   if(x.size() % 2 == 1)
       return 0;

   for(int i = 0 ; i < 26 ; i++)
      d[i] = 0 , e[i] = 0;

   for(int i = 0 ; i < x.size() ; i++)
      d[x[i]-'a']++ , e[y[i]-'a']++;

   a = x.size() / 2;

   for(int i = 0 ; i < 26 ; i++){
      if(d[i] != e[i]) return 0;
      d[i] = 0 , e[i] = 0;
   }
   if(bberry(x.substr(0 , a) , x.substr(a , x.size()-1)) && bberry(y.substr(0 , a) , y.substr(a , y.size()-1)))
      return 1;

   if(bberry(x.substr(0 , a) , y.substr(a , y.size()-1)) && bberry(y.substr(0 , a) , x.substr(a , x.size()-1)))
      return 1;
   return 0;
}

int main()
{

   cin>>s>>q;

   if(bberry(s , q)) cout << "YES";
   else              cout << "NO";

   return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a,b,c,d[30],e[30];
string s , q;
// made on blackberry not on computer
int bberry(string x , string y)
{
   if(x == y)
       return 1;
   if(x.size() % 2 == 1)
       return 0;

   for(int i = 0 ; i < 26 ; i++)
      d[i] = 0 , e[i] = 0;

   for(int i = 0 ; i < x.size() ; i++)
      d[x[i]-'a']++ , e[y[i]-'a']++;

   a = x.size() / 2;

   for(int i = 0 ; i < 26 ; i++)
      if(d[i] != e[i]) return 0;

   if(bberry(x.substr(0 , a) , x.substr(a , x.size()-1)) && bberry(y.substr(0 , a) , y.substr(a , y.size()-1)))
      return 1;

   if(bberry(x.substr(0 , a) , y.substr(a , y.size()-1)) && bberry(y.substr(0 , a) , x.substr(a , x.size()-1)))
      return 1;
}

int main()
{

   cin>>s>>q;

   if(bberry(s , q)) cout << "YES";
   else              cout << "NO";

   return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
#define N 200010
typedef unsigned long long ll;
char A[N],B[N];
ll C1[N],C2[N],pre[N];
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
bool pd(int l1,int r1,int l2,int r2)
{
    /*int t=r1-l1+1;
    ll pd1=C1[r1]-C1[l1-1]*pre[t],pd2=C2[r2]-C2[l2-1]*pre[t];
    if(pd1==pd2)
        return true;*/
    int t=l1-l2;
    bool qwer=true;
    for(int i=l1;i<=r1&&qwer;i++)
    {
        if(A[i]!=B[i-t])
            qwer=false;
    }
    if(qwer)
        return true;
    if((r1-l1+1)%2==1)
        return false;
    else
    {
        int mid1=(l1+r1)/2,mid2=(l2+r2)/2;
        bool t1=pd(l1,mid1,mid2+1,r2)&&pd(mid1+1,r1,l2,mid2);
        bool t2=pd(l1,mid1,l2,mid2)&&pd(mid1+1,r1,mid2+1,r2);
        return t1||t2;
    }
}
int main()
{
    scanf("%s",A+1);
    scanf("%s",B+1);
    pre[0]=1;
    /*for(int i=1;i<=strlen(A+1);i++)
    {
        C1[i]=C1[i-1]*107+A[i]-'a';
        C2[i]=C2[i-1]*107+B[i]-'a';
        pre[i]=pre[i-1]*107;
    }*/
    if(pd(1,strlen(A+1),1,strlen(B+1)))
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
#define N 200010
char A[N],B[N];
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
bool pd(int l1,int r1,int l2,int r2)
{
    int t=l1-l2;
    bool qwer=true;
    for(int i=l1;i<=r1&&qwer;i++)
    {
        if(A[i]!=B[i-t])
            qwer=false;
    }
    if(qwer)
        return true;
    if((r1-l1+1)%2==1)
        return false;
    else
    {
        int mid1=(l1+r1)/2,mid2=(l2+r2)/2;
        bool t1=pd(l1,mid1,mid2+1,r2)&&pd(mid1+1,r1,l2,mid2);
        bool t2=pd(l1,mid1,l2,mid2)&&pd(mid1+1,r1,mid2+1,r2);
        return t1||t2;
    }
}
int main()
{
    scanf("%s",A+1);
    scanf("%s",B+1);
    if(pd(1,strlen(A+1),1,strlen(B+1)))
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
#define N 200010
typedef unsigned long long ll;
char A[N],B[N];
ll C1[N],C2[N],pre[N];
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
bool pd(int l1,int r1,int l2,int r2)
{
    /*int t=r1-l1+1;
    ll pd1=C1[r1]-C1[l1-1]*pre[t],pd2=C2[r2]-C2[l2-1]*pre[t];
    if(pd1==pd2)
        return true;*/
    int t=l1-l2;
    bool qwer=true;
    for(int i=l1;i<=r1&&qwer;i++)
    {
        if(A[i]!=B[i-t])
            qwer=false;
    }
    if(qwer)
        return true;
    if((r1-l1+1)%2==1)
        return false;
    else
    {
        int mid1=(l1+r1)/2,mid2=(l2+r2)/2;
        bool t1=pd(l1,mid1,mid2+1,r2)&&pd(mid1+1,r1,l2,mid2);
        bool t2=pd(l1,mid1,l2,mid2)&&pd(mid1+1,r1,mid2+1,r2);
        return t1||t2;
    }
}
int main()
{
    scanf("%s",A+1);
    scanf("%s",B+1);
    pre[0]=1;
    for(int i=1;i<=strlen(A+1);i++)
    {
        C1[i]=C1[i-1]*107+A[i]-'a';
        C2[i]=C2[i-1]*107+B[i]-'a';
        pre[i]=pre[i-1]*107;
    }
    if(pd(1,strlen(A+1),1,strlen(B+1)))
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
#define N 200010
typedef unsigned long long ll;
char A[N],B[N];
ll C1[N],C2[N],pre[N];
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
bool pd(int l1,int r1,int l2,int r2)
{
    int t=r1-l1+1;
    ll pd1=C1[r1]-C1[l1-1]*pre[t],pd2=C2[r2]-C2[l2-1]*pre[t];
    if(pd1==pd2)
        return true;
    if(t%2==1)
        return false;
    else
    {
        int mid1=(l1+r1)/2,mid2=(l2+r2)/2;
        bool t1=pd(l1,mid1,mid2+1,r2)&&pd(mid1+1,r1,l2,mid2);
        bool t2=pd(l1,mid1,l2,mid2)&&pd(mid1+1,r1,mid2+1,r2);
        return t1||t2;
    }
}
int main()
{
    scanf("%s",A+1);
    scanf("%s",B+1);
    pre[0]=1;
    for(int i=1;i<=strlen(A+1);i++)
    {
        C1[i]=C1[i-1]*107+A[i]-'a';
        C2[i]=C2[i-1]*107+B[i]-'a';
        pre[i]=pre[i-1]*107;
    }
    if(pd(1,strlen(A+1),1,strlen(B+1)))
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
#define N 200010
typedef unsigned long long ll;
char A[N],B[N];
ll C1[N],C2[N],pre[N];
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
bool pd(int l1,int r1,int l2,int r2)
{
    int t=r1-l1+1;
    ll pd1=C1[r1]-C1[l1-1]*pre[t],pd2=C2[r2]-C2[l2-1]*pre[t];
    if(pd1==pd2)
        return true;
    if(t%2==1)
        return false;
    else
    {
        int mid1=(l1+r1)/2,mid2=(l2+r2)/2;
        bool t1=pd(l1,mid1,mid2+1,r2)&&pd(mid1+1,r1,l2,mid2);
        bool t2=pd(l1,mid1,l2,mid2)&&pd(mid1+1,r1,mid2+1,r2);
        return t1||t2;
    }
}
int main()
{
    scanf("%s",A+1);
    scanf("%s",B+1);
    int len=strlen(A+1);
    pre[0]=1;
    for(int i=1;i<=len;i++)
    {
        C1[i]=C1[i-1]*107+A[i]-'a';
        C2[i]=C2[i-1]*107+B[i]-'a';
        pre[i]=pre[i-1]*107;
    }
    if(pd(1,len,1,len))
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
#define N 200010
typedef unsigned long long ll;
char A[N],B[N];
ll C1[N],C2[N],pre[N];
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
bool pd(int l1,int r1,int l2,int r2)
{
    /*int t=r1-l1+1;
    ll pd1=C1[r1]-C1[l1-1]*pre[t],pd2=C2[r2]-C2[l2-1]*pre[t];
    if(pd1==pd2)
        return true;*/
    int t=l1-l2;
    bool qwer=true;
    for(int i=l1;i<=l2&&qwer;i++)
    {
        if(A[i]!=B[i-t])
            qwer=false;
    }
    if(qwer)
        return true;
    if((r1-l1+1)%2==1)
        return false;
    else
    {
        int mid1=(l1+r1)/2,mid2=(l2+r2)/2;
        bool t1=pd(l1,mid1,mid2+1,r2)&&pd(mid1+1,r1,l2,mid2);
        bool t2=pd(l1,mid1,l2,mid2)&&pd(mid1+1,r1,mid2+1,r2);
        return t1||t2;
    }
}
int main()
{
    scanf("%s",A+1);
    scanf("%s",B+1);
    pre[0]=1;
    for(int i=1;i<=strlen(A+1);i++)
    {
        C1[i]=C1[i-1]*107+A[i]-'a';
        C2[i]=C2[i-1]*107+B[i]-'a';
        pre[i]=pre[i-1]*107;
    }
    if(pd(1,strlen(A+1),1,strlen(B+1)))
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
#define N 200010
char A[N],B[N];
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
bool pd(int l1,int r1,int l2,int r2)
{
    int t=l1-l2;
    bool qwer=true;
    for(int i=l1;i<=r1&&qwer;i++)
    {
        if(A[i]!=B[i-t])
            qwer=false;
    }
    if(qwer)
        return true;
    if((r1-l1+1)%2==1)
        return false;
    else
    {
        int mid1=(l1+r1)/2,mid2=(l2+r2)/2;
        return pd(l1,mid1,mid2+1,r2)&&pd(mid1+1,r1,l2,mid2);
    }
}
int main()
{
    scanf("%s",A+1);
    scanf("%s",B+1);
    if(pd(1,strlen(A+1),1,strlen(B+1)))
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
#define N 200010
typedef unsigned long long ll;
char A[N],B[N];
ll C1[N],C2[N],pre[N];
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
bool pd(int l1,int r1,int l2,int r2)
{
    int t=r1-l1+1;
    ll pd1=C1[r1]-C1[l1-1]*pre[t],pd2=C2[r2]-C2[l2-1]*pre[t];
    if(pd1==pd2)
        return true;
    if(t%2==1)
        return false;
    else
    {
        int mid1=(l1+r1)/2,mid2=(l2+r2)/2;
        bool t1=pd(l1,mid1,mid2+1,r2)&&pd(mid1+1,r1,l2,mid2);
        bool t2=pd(l1,mid1,l2,mid2)&&pd(mid1+1,r1,mid2+1,r2);
        return t1||t2;
    }
}
int main()
{
    scanf("%s",A+1);
    scanf("%s",B+1);
    int len=strlen(A+1);
    pre[0]=1;
    for(int i=1;i<=len;i++)
    {
        C1[i]=C1[i-1]*107+A[i]-'a';
        C2[i]=C2[i-1]*107+B[i]-'a';
        pre[i]=pre[i-1]*107;
    }
    if(pd(1,strlen(A+1),1,strlen(B+1)))
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
#define N 200010
typedef unsigned long long ll;
char A[N],B[N];
ll C1[N],C2[N],pre[N];
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
bool pd(int l1,int r1,int l2,int r2)
{
    int t=r1-l1+1;
    ll pd1=C1[r1]-C1[l1-1]*pre[t],pd2=C2[r2]-C2[l2-1]*pre[t];
    if(pd1==pd2)
        return true;
    if(t%2==1)
        return false;
    else
    {
        int mid1=(l1+r1)/2,mid2=(l2+r2)/2;
        if(pd(l1,mid1,mid2+1,r2)&&pd(mid1+1,r1,l2,mid2))
            return 1;
        if(pd(l1,mid1,l2,mid2)&&pd(mid1+1,r1,mid2+1,r2))
            return 1;
        return 0;
    }
}
int main()
{
    scanf("%s",A+1);
    scanf("%s",B+1);
    int len=strlen(A+1);
    pre[0]=1;
    for(int i=1;i<=len;i++)
    {
        C1[i]=C1[i-1]*107+A[i]-'a';
        C2[i]=C2[i-1]*107+B[i]-'a';
        pre[i]=pre[i-1]*107;
    }
    if(pd(1,len,1,len))
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define loop(i,a,b) for(int i=a;i<b;i++)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
string a,b,x;
int m,n,y;
string substring(string s,int st,int en)
{
	x="";
	int j=0,i;
	for(i=st;i<en;i++)
	{
		x+=s[i];
		//cout<<x[j];
		//j++;
	}
	//x[j++]=0;
	//cout<<j<<endl;
	//cout<<x.size()<<endl<<x;

	return x;
}
int ans(string s,string t)
{
	int mid,x=0,y=0,l=0,k=0,z=s.size();
	//cout<<s<<endl;//<<t<<endl;
	if(s==t)
		return 1;
	if((z)%2==1)
	{
		return 0;
	}
	string g1,g2,g3,g4;
	g1.clear();
	g2.clear();g3.clear();g4.clear();
	g1=s.substr(0,z/2);
	g2=t.substr(z/2,z/2);
	g3=t.substr(0,z/2);
	g4=s.substr(z/2,z/2);
	x=ans(g1,g3);
	y=ans(g1,g2);
	l=ans(g4,g3);
	k=ans(g4,g2);
	//cout<<x<<" "<<y<<" "<<l<<" "<<k<<endl;
	return ((x*k)+(l*y));
}
	//x=ans(s.substring(0,s.size()),t.substring(0,t.size()));
int main()
{
	int k=0;
	cin>>a>>b;
	k=ans(a,b);
	//cout<<k;
	if(k)
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define loop(i,a,b) for(int i=a;i<b;i++)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
string a,b,x;
int m,n,y;
string substring(string s,int st,int en)
{
	x="";
	int j=0,i;
	for(i=st;i<en;i++)
	{
		x+=s[i];
		//cout<<x[j];
		//j++;
	}
	//x[j++]=0;
	//cout<<j<<endl;
	//cout<<x.size()<<endl<<x;

	return x;
}
bool ans(string s,string t)
{
	int z=s.size();
	//cout<<s<<endl;//<<t<<endl;
	if(s==t)
		return 1;
	if((z)%2)
	{
		return 0;
	}
	string g1,g2,g3,g4;
	int z1=z/2;
	g1=s.substr(0,z1);
	g2=t.substr(z1,z1);
	g3=t.substr(0,z1);
	g4=s.substr(z1,z1);
	return((ans(g1,g3)&&ans(g4,g2))||(ans(g4,g3)&&ans(g1,g2)));
	//return ((x&&k)||(l&&y));
}
	//x=ans(s.substring(0,s.size()),t.substring(0,t.size()));
int main()
{
	int k=0;
	cin>>a>>b;
	k=ans(a,b);
	//cout<<k;
	if(k)
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define loop(i,a,b) for(int i=a;i<b;i++)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
string a,b;
int m,n,y;
/*string substring(string s,int st,int en)
{
	x="";
	int j=0,i;
	for(i=st;i<en;i++)
	{
		x+=s[i];
		//cout<<x[j];
		//j++;
	}
	//x[j++]=0;
	//cout<<j<<endl;
	//cout<<x.size()<<endl<<x;

	return x;
}*/
bool ans(string s,string t)
{
	int z=s.length();
	//cout<<s<<endl;//<<t<<endl;
	if(s==t)
		return 1;
	if((z)%2)
	{
		return 0;
	}
	//string g1,g2,g3,g4;
	int z1=z/2;
	string g1=s.substr(0,z1), g2=t.substr(z1,z1),g3=t.substr(0,z1),g4=s.substr(z1,z1);
	return((ans(g1,g3)&&ans(g4,g2))||(ans(g4,g3)&&ans(g1,g2)));
	//return ((x&&k)||(l&&y));
}
	//x=ans(s.substring(0,s.size()),t.substring(0,t.size()));
int main()
{
	//int k=0;
	cin>>a>>b;

	//cout<<k;
	if(ans(a,b))
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define loop(i,a,b) for(int i=a;i<b;i++)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
string a,b;
int m,n,y;
/*string substring(string s,int st,int en)
{
	x="";
	int j=0,i;
	for(i=st;i<en;i++)
	{
		x+=s[i];
		//cout<<x[j];
		//j++;
	}
	//x[j++]=0;
	//cout<<j<<endl;
	//cout<<x.size()<<endl<<x;

	return x;
}*/
bool ans(string s,string t)
{

	//cout<<s<<endl;//<<t<<endl;
	if(s==t)
		return 1;
	if((s.size())%2)
	{
		return 0;
	}
	//string g1,g2,g3,g4;
	int z1=s.size()/2;
	string g1=s.substr(0,z1), g2=t.substr(z1,z1),g3=t.substr(0,z1),g4=s.substr(z1,z1);
	return((ans(g1,g3)&&ans(g4,g2))||(ans(g4,g3)&&ans(g1,g2)));
	//return ((x&&k)||(l&&y));
}
	//x=ans(s.substring(0,s.size()),t.substring(0,t.size()));
int main()
{
	//int k=0;
	ios::sync_with_stdio(false);
	cin>>a>>b;

	//cout<<k;
	if(ans(a,b))
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}