'use strict';
const main = input => {
  let S = input[0], T = input[1];
  let s = [], t = [];
  for(let i=0; i<S.length; i++) {
    s.push(S.charCodeAt(i));
    t.push(T.charCodeAt(i));
  }
  let arr = [];
  // console.log(s, t);
  for(let i=0; i<s.length-1; i++) {
    if (s[i] != t[i]) {
      for(let j=i+1; j<s.length; j++) {
        if (s[j] == s[i]) {
          s[j] = t[i];
          // console.log(i, j);
          
        } else if (s[j] == t[i]) {
          s[j] = s[i];
          // console.log( i, j);
          
        }
      }
      
      
      s[i] = t[i];
      // console.log(s, t);
      
    }

  }
  // console.log(s, t);
  for(let i=0; i<s.length; i++) {
    if (s[i] != t[i]) {
      console.log('No');
      return;
    }
  }
  console.log('Yes');
  return;
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));