function main(input) {
  var A = input[0];
  var B = input[1];
  var mapA = {};
  var mapB = {};
  for(var i=0;i<A.length;i++){
    if(!mapA[A[i]]){
      mapA[A[i]] = {};
    }else{
      if(mapA[A[i]][B[i]] === undefined){
        console.log('No');
        return;
      }
    }
    if(!mapB[B[i]]){
      mapB[B[i]] = {};
    }else{
      if(mapB[B[i]][A[i]] === undefined){
        console.log('No');
        return;
      }
    }
    mapA[A[i]][B[i]] = true;
    mapB[B[i]][A[i]] = true;
  }
  console.log("Yes");
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))
