Lets say I have a diophantine equation ,

**aX - bY = c**

Now, for some (a,b,c) I may not have any integer solution at all. But lets say , I write the equation in this way ,

**aX - bY = c + p**

p is an integer . (positive or negative)

So, I can increase the value of **c** by **(c+p)** if there are no solution for (a,b,c).
I need to find a triplet **(a,b,c+p)** for which solution exist and p is minimum(absolute value).

If , already I have solution for (a,b,c) then p is just 0.

How to solve this problem ?