Figure out your BMR here https://www.myfitnesspal.com/tools/bmr-calculator (Your BMR is the amount of calories your body needs just to be alive, think in a coma, alive but not moving).
And don't eat more than that per day and you should be fine.
My current BMR is 2047, so barring any medication that causes weight gain etc, if I laid in bed all day and didn't consume 2047 calories, I'd be at a deficit and my body would be forced to use it's energy stores.
Stay under your BMR if you can't exercise and you shouldn't have a problem with weight gain.