Elsa had 40 marbles - 3 - 5 = <<40-3-5=32>>32 marbles.
Elsa then gained 12 marbles + 32 = <<12+32=44>>44 marbles.
At dinner Elsa received 2 * 5 marbles from Susie = <<2*5=10>>10 marbles.
In total Elsa had 44 marbles + 10 = <<44+10=54>>54 marbles.
#### 54