console.log((args=>{
  const [S,T] = args.trim().split('\n');
  const L = S.length, a = 'a'.charCodeAt(0);
  const m = Array(26).fill('');
  for ( let i = 0; i < L; i++ ) {
    const s = S.charCodeAt(i) - a;
    if ( !m[s] ) m[s] = T[i];
    else if ( m[s] !== T[i] ) return 'No';
    const t = T.charCodeAt(i);
    if ( !m[t] ) m[t] = S[i];
    else if ( m[t] !== S[i] ) return 'No';
  }
  return 'Yes';
})(require('fs').readFileSync('/dev/stdin', 'utf8')));