#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(vector<int>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

bool compare_vect(vector<int>& A,vector<int> &B)
{
  return A.size() > B.size();
}
void solve(void)
{
  string S;
  string T;
  cin>>S>>T;
  vector<vector<int> > DATA_S(26);
  vector<vector<int> > DATA_T(26);
  for (int i = 0; i < S.size(); i++)
  {
    int X = S[i] - 'a';
    DATA_S[X].push_back(i);
    
  }
  for (int i = 0; i < DATA_S.size(); i++)
  {
    sort(DATA_S[i].begin(),DATA_S[i].end());
  }

  for (int i = 0; i < T.size(); i++)
  {
    int X = T[i] - 'a';
    DATA_T[X].push_back(i);
  }
  for (int i = 0; i < DATA_T.size(); i++)
  {
    sort(DATA_T[i].begin(),DATA_T[i].end());
  }
  
  sort(DATA_S.begin(),DATA_S.end(),compare_vect);
  sort(DATA_T.begin(),DATA_T.end(),compare_vect);
  // for (int i = 0; i < 26; i++)
  // {
  //   cout<<DATA_T[i].size()<<endl;
  // }
  
  bool check = 1;
  for (int i = 0; i < 26; i++)
  {
    if(DATA_S[i].size() != DATA_T[i].size())
    {
      check = 0;
    }
    else
    {
      // for (int j = 0; j < DATA_S[i].size(); j++)
      // {
      //   if(DATA_S[i][j] != DATA_T[i][j])
      //   {
      //     check = 0;
      //     DEBUG("DEBUG");
      //     DEBUG(DATA_S[i][j]);
      //     DEBUG(DATA_T[i][j]);
      //   }
      //   else
      //   {

      //   }
        
      // }
      
    }
    
  }

  if(check == true)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  
  
  
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 5124