{"problem":{"name":"Replacing Integer","description":{"content":"Given any integer $x$, Aoki can do the operation below. Operation: Replace $x$ with the absolute difference of $x$ and $K$. You are given the initial value of an integer $N$. Find the minimum possible","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc161_c"},"statements":[{"statement_type":"Markdown","content":"Given any integer $x$, Aoki can do the operation below.\nOperation: Replace $x$ with the absolute difference of $x$ and $K$.\nYou are given the initial value of an integer $N$. Find the minimum possible value taken by $N$ after Aoki does the operation zero or more times.\n\n## Constraints\n\n*   $0 ≤ N ≤ 10^{18}$\n*   $1 ≤ K ≤ 10^{18}$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $K$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc161_c","tags":[],"sample_group":[["7 4","1\n\nInitially, $N=7$.\nAfter one operation, $N$ becomes $|7-4| = 3$.\nAfter two operations, $N$ becomes $|3-4| = 1$, which is the minimum value taken by $N$."],["2 6","2\n\n$N=2$ after zero operations is the minimum."],["1000000000000000000 1","0"]],"created_at":"2026-03-03 11:01:14"}}