"I say we must move forward, not backward; upward, not forward; and always twirling, twirling, twirling towards freedom!"
Kodos, a former candidate for President of the United States.
Kodos comes from the planet Rigel VII. The speech worked on you, so you have decided to twirl toward freedom as well. In this problem, freedom means getting as far from your starting point as you can.
The galaxy is a two-dimensional plane. Your ship starts at the origin (0,0), and the galaxy has N stars. Every minute you may pick one star and rotate your ship 90 degrees clockwise around that star. You may also stay where you are for that minute.
How far from the origin can the ship be after M minutes?

The picture shows the first three rotations of one possible path for the first example. That path is not part of an optimal plan.