Is the U(1) gauge theory in 2+1D dual to a U(1) or an integer XY model?
Let't me give it a shot. One possible explanation is to imagine we soften the integer condition for $m$'s in $S_{2}$. Then, the cosine term in $S_{1}$ is what we want to add because when $K$ is large, it enforce the integer condition and go back to $S_{2}$.