He rents for d days, but two days are free, so he pays for only d - 2 days.
The rental fee is $45 per day, so for d - 2 days, he pays 45(d - 2). The total he pays is $315, so the equation is
45(d - 2) = 315
Now we solve the equation to find d, the number of days.
45(d - 2) = 315
45d - 90 = 315
45d = 405
d = 9
The number of days is 9.