A queen on her deathbed makes her son swear to marry only that girl who can fit into her shoes. When his sister notices that she herself would be that girl, she goes away in order to avert the threat of incest and to find another woman who can fit into the shoes. In a lonely hut in the woods, she makes friends with Šofolica, the daughter of a witch, whom the shoes fit.
The girls flee from the woods to return to the royal court. Along the way, they both fall into a well. After their death two elderberry bushes are growing from the well. A shepherd makes flutes from their branches. When they are played, not the sound of the flute is heard, but a song about the story of the girls. The shepherd demonstrates the singing flutes to the king, who listens to the song and orders food to be served. Sheperd and king hide in the room, while the flutes are transformed into the two girls, who begin to eat the served meals. The king and the shepherd succeed in taking hold of the girls and, in this way, the girls are released from the spell. Together they celebrate their weddings, Šofolica with the prince and the princess with the shepherd.