<p>You are given an integer <code>n</code>, the number of teams in a tournament that has strange rules:</p>
<ul>
<li>If the current number of teams is <strong>even</strong>, each team gets paired with another team. A total of <code>n / 2</code> matches are played, and <code>n / 2</code> teams advance to the next round.</li>
<li>If the current number of teams is <strong>odd</strong>, one team randomly advances in the tournament, and the rest gets paired. A total of <code>(n - 1) / 2</code> matches are played, and <code>(n - 1) / 2 + 1</code> teams advance to the next round.</li>
</ul>
<p>Return <em>the number of matches played in the tournament until a winner is decided.</em></p>