type GameParams = { N: int; K: int } type Player = Black | White let simulate n k = (n - 1) % (k + 1) |> function | 0 -> White | _ -> Black Array.init 1000 (fun _ -> let t = stdin.ReadLine().Split() |> Array.map int { N = t.[0]; K = t.[1] }) |> Array.map (fun x -> simulate x.N x.K) |> Array.where ((=) Black) |> Array.length |> stdout.WriteLine