import sequtils,strutils var arr = stdin.readLine.split.map parseInt echo if arr[0] mod 2 == 0: (arr[0] div 2 - 1) mod arr[1] * arr[1] else: arr[0] div 2 mod arr[1] * arr[1]