You eat X calories, you use Y calories. If X > Y most of the difference is stored (as fat), if Y > X your body burn the energy stored (fat, at some point, but it depends).
It's simple math and it's scientifically proven. 2000 kcal are 2000kcal, it doesn't matter if they come from a single burger or 10kg of lettuce.
I'd say it does matter, 10 kg of lettuce will take forever to digest and will require way more energy. Individual metabolism quirks will also affect how much of it comes out of the other end relatively intact.
It's simple math and it's scientifically proven. 2000 kcal are 2000kcal, it doesn't matter if they come from a single burger or 10kg of lettuce.
It's not what you eat, it is how much you eat.