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

	var g2 = Set[Char]()

	for(i<-0 until 26){
		g2 = g2 + ('a'.toInt + i).toChar
	}

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

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

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

} 