<p>You are given a string <code>num</code>, representing a large integer, and an integer <code>k</code>.</p>
<p>We call some integer <strong>wonderful</strong> if it is a <strong>permutation</strong> of the digits in <code>num</code> and is <strong>greater in value</strong> than <code>num</code>. There can be many wonderful integers. However, we only care about the <strong>smallest-valued</strong> ones.</p>
<ul>
<li>For example, when <code>num = "5489355142"</code>:
<ul>
<li>The 1<sup>st</sup> smallest wonderful integer is <code>"5489355214"</code>.</li>
<li>The 2<sup>nd</sup> smallest wonderful integer is <code>"5489355241"</code>.</li>
<li>The 3<sup>rd</sup> smallest wonderful integer is <code>"5489355412"</code>.</li>
<li>The 4<sup>th</sup> smallest wonderful integer is <code>"5489355421"</code>.</li>
</ul>
</li>
</ul>
<p>Return <em>the <strong>minimum number of adjacent digit swaps</strong> that needs to be applied to </em><code>num</code><em> to reach the </em><code>k<sup>th</sup></code><em><strong> smallest wonderful</strong> integer</em>.</p>
<p>The tests are generated in such a way that <code>k<sup>th</sup></code> smallest wonderful integer exists.</p>