The recent reports on 203 K superconductivity in compressed hydrogen sulfide, H$_3$S, has attracted great interest in sulfur-hydrogen system under high pressure. Here, we investigated the superconductivity of P-doped and Cl-doped H$_3$S using the first-principles calculations based on the supercell method, which gives more reliable results on the superconductivity in doped systems than the calculations based on the virtual crystal approximation reported earlier. The superconducting critical temperature is increased from 189 to 212 K at 200 GPa in a cubic $Imbar{3}m$ phase by the 6.25 % P doping, whereas it is decreased to 161 K by the 6.25 % Cl doping. Although the Cl doping weakens the superconductivity, it causes the $Imbar{3}m$ phase to be stabilized in a lower pressure region than that in the non-doped H$_3$S.