#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int b[26]{0}, c[26]{0};
  for(int i = 0; i < n; i++){
    b[s[i] - 'a']++;
    c[t[i] - 'a']++;
  }
  sort(b, b + 26);
  sort(c, c + 26);
  for(int i = 0; i < 26; i++){
    if(b[i] != c[i]){
      cout << "No" << endl;
      return(0);
    }
  }
  cout << "Yes" << endl;
}