Suppose the Josephus problem can be solved by the following pseudocode.
r := 0
for i from 1 to n do
r := (r + k) mod i
return r
A programmer misread the code and wrote it as follows instead.
r := 0
for i from 1 to n do
r := r + (k mod i)
return r
Given n and k, write a program that prints the value returned by the incorrect code.
The first line contains two integers n and k. (1 <= n, k <= 10^9)
Print the value returned by the incorrect code.