We generalize the multiple cover formula of Y. Toda (proved by Maulik-Thomas) for counting invariants for semistable coherent sheaves on local K3 surfaces to semistable twisted sheaves over twisted local K3 surfaces. As applications we calculate the $SU(r)/zz_r$-Vafa-Witten invariants for K3 surfaces for any rank $r$ defined by Jiang for the Langlands dual group $SU(r)/zz_r$ of the gauge group $SU(r)$. We generalize and prove the S-duality conjecture of Vafa-Witten of K3 surfaces for all higher ranks based on the result of Tanaka-Thomas on the $SU(r)$-Vafa-Witten invariants.