We want to maximize the profit, p(x) = -x^2 + 62x + 77. The graph of this function is a parabola that opens down. The x-coordinate of the vertex is x = -b/(2a), which here is x = -62 / (2*-1), or 31. So, we'll maximize John's profit if we advise him to sell 31 hot dogs.