{"raw_statement":[{"iden":"problem statement","content":"You are given an integer $X$. The following action on this integer is called an _operation_.\n\n*   Choose and do one of the following.\n    *   Add $1$ to $X$.\n    *   Subtract $1$ from $X$.\n\nThe terms in the arithmetic progression $S$ with $N$ terms whose initial term is $A$ and whose common difference is $D$ are called _good numbers_.  \nConsider performing zero or more operations to make $X$ a good number. Find the minimum number of operations required to do so."},{"iden":"constraints","content":"*   All values in input are integers.\n*   $-10^{18} \\le X,A \\le 10^{18}$\n*   $-10^6 \\le D \\le 10^6$\n*   $1 \\le N \\le 10^{12}$"},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$X$ $A$ $D$ $N$"},{"iden":"sample input 1","content":"6 2 3 3"},{"iden":"sample output 1","content":"1\n\nSince $A=2,D=3,N=3$, we have $S=(2,5,8)$.  \nYou can subtract $1$ from $X$ once to make $X=6$ a good number.  \nIt is impossible to make $X$ good in zero operations."},{"iden":"sample input 2","content":"0 0 0 1"},{"iden":"sample output 2","content":"0\n\nWe might have $D=0$. Additionally, no operation might be required."},{"iden":"sample input 3","content":"998244353 -10 -20 30"},{"iden":"sample output 3","content":"998244363"},{"iden":"sample input 4","content":"\\-555555555555555555 -1000000000000000000 1000000 1000000000000"},{"iden":"sample output 4","content":"444445"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}