Díky šastná náhoda se Cimrman seznámil se Sigmund Freud.

The main verb is "seznámil se" 3sg. past tense form of seznámit se.

The subject is the nominative form Cimrman.

seznámit se often takes the prepositional phrase "s(e) + instrumental case"

díky is a preposition "thanks to" taking the dative case