<p>Your car starts at position <code>0</code> and speed <code>+1</code> on an infinite number line. Your car can go into negative positions. Your car drives automatically according to a sequence of instructions <code>'A'</code> (accelerate) and <code>'R'</code> (reverse):</p>
<ul>
<li>When you get an instruction <code>'A'</code>, your car does the following:
<ul>
<li><code>position += speed</code></li>
<li><code>speed *= 2</code></li>
</ul>
</li>
<li>When you get an instruction <code>'R'</code>, your car does the following:
<ul>
<li>If your speed is positive then <code>speed = -1</code></li>
<li>otherwise <code>speed = 1</code></li>
</ul>
Your position stays the same.</li>
</ul>
<p>For example, after commands <code>"AAR"</code>, your car goes to positions <code>0 --> 1 --> 3 --> 3</code>, and your speed goes to <code>1 --> 2 --> 4 --> -1</code>.</p>
<p>Given a target position <code>target</code>, return <em>the length of the shortest sequence of instructions to get there</em>.</p>