#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
  string S,T;
  cin >> S >> T;
  vector<int> p(26,0),q(26,0);
  rep(i,S.size()){
    p[S[i]-'a']++;
    q[T[i]-'a']++;
  }
  sort(p.begin(),p.end());
  sort(q.begin(),q.end());
  bool flag = true;
  rep(i,26) if(p[i]!=q[i]) flag=false;
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}