object Main extends App {
	var s = scala.io.StdIn.readLine.toList
	var t = scala.io.StdIn.readLine.toList
	var map = Map[Char, Char]()

	val size = s.size
	var flag = true

	for(i<-0 until size){
		val a = s.head
		val b = t.head
		s = s.tail
		t = t.tail

		map.get(b) match {
			case None => map = map + (b->a)
			case Some(z) => if(z != a) flag = false
		}
	}

	if(flag) println("Yes")
	else println("No")

} 
