The problem of finding the shape of a body with smallest drag in a flow governed by the two-dimensional steady Navier-Stokes equations is considered. The flow is expressed in terms of a streamfunction which satisfies a fourth-order partial differential equation with the biharmonic operator as principal part. Using the adjoint variable approach, both the first- and second-order necessary conditions for the shape with smallest drag are obtained. An algorithm for the calculation of the optimal shape is proposed in which the first variations of solutions of the direct and adjoint problems are incorporated. Numerical examples show that the algorithm can produce the optimal shape successfully.