The Bruins have $8.6m in deadline cap space. They'll move DeBrusk out at the deadline for another $3.6, totaling $12.2m in contracts they can bring in.
Hertl is $5.6
Miller is $3.8
McEwen is $825k
Totals $10.2m
They might have to play with the two-way contracts like Vaak Swayman to meet roster limits (until the playoffs) but they can add those new players and be under the cap.
Next year, if Bergeron retires, Studnicka takes his spot and you're cap compliant. If Bergeron wants to keep playing then you'd likely have to move Reilly and either buyout or retain and trade Foligno to free up the money for him.