#include <fstream>
#include <algorithm>

using namespace std;

ifstream fin( "ancient.in" );
ofstream fout( "ancient.out" );

const int MAX = 100;

char s1[MAX+1], s2[MAX+1], t[MAX+1];
int L;

void ReadData()
{
   fin >> s1 >> s2;
   L = strlen( s1 );
}

void Shift( char *s, int d )
{
   for( ; *s; ++s )
      *s = (*s-'A'+d+26)%26+'A';
}

bool Work()
{
   sort( s1, s1+L );
   int i;
   for( i = 0; i<L; ++i )
   {
      strcpy( t, s2 );
      swap( t[0], t[i] );
      Shift( t, s1[0]-t[0] );
      sort( t, t+L );
      if( strcmp( s1, t )==0 )
         return true;
   }
   return false;
}

void Output( bool res )
{
   fout << (res ? "YES" : "NO");
}

int main()
{
   ReadData();
   Output( Work() );
   return 0;
}
