#include <fstream>
#include <algorithm>

using namespace std;

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

const int MAX = 256;

int cnt1[MAX], cnt2[MAX];

int Find( int s )
{
   int i;
   for( i = 0; i<MAX; ++i )
      if( cnt2[i]==s )
         return i;
   return -1;
}

bool Work()
{
   char s[MAX], *ptr;
   fin >> s;
   for( ptr = s; *ptr; ++ptr )
      ++cnt1[*ptr];
   fin >> s;
   for( ptr = s; *ptr; ++ptr )
      ++cnt2[*ptr];
   int i, k;
   for( i = 0; i<256; ++i )
      if( cnt1[i] )
      {
         k = Find( cnt1[i] );
         if( k==-1 )
            return false;
         cnt2[k] = 0;
      }
   return true;
}

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

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