n, k = io.read("*n", "*n") if n == 1 then print(1) elseif k ~= n - 1 then print(n - 1) else print(n) end