#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  string s, t;
  cin >> s >> t;
  vector<int> tq(26, 0), sq(26, 0);
  rep(i,t.size())
  {
    tq[t[i] - 'a']++;
    sq[s[i] - 'a']++;
  }
  sort(tq.begin(), tq.end());
  sort(sq.begin(), sq.end());
  rep(i,26)
    if (tq[i] != sq[i]) {
      cout << "No";
      return 0;
    }
  cout << "Yes";
  return 0;
}
