{"raw_statement":[{"iden":"problem statement","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."},{"iden":"constraints","content":"*   $0 ≤ N ≤ 10^{18}$\n*   $1 ≤ K ≤ 10^{18}$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $K$"},{"iden":"sample input 1","content":"7 4"},{"iden":"sample output 1","content":"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$."},{"iden":"sample input 2","content":"2 6"},{"iden":"sample output 2","content":"2\n\n$N=2$ after zero operations is the minimum."},{"iden":"sample input 3","content":"1000000000000000000 1"},{"iden":"sample output 3","content":"0"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}