fscanf(STDIN, "%d", $N); fscanf(STDIN, "%d", $M); $num = floor($N/1000); $aaa = ($N / 1000) - ($num % $M); echo $aaa / $M;