CMIMC 2017 Power Problem 21

In the worst case, how many comparisons are made?