It gains a foot a day, so by the end of day 27 it’s 27 feet up. On day 28 it climbs the last 3 feet and is out before night can drag it back.

The usual answer is 30, from counting a foot a day all the way to the top.