The Strange Shopkeeper and His First Loss

Limits 1s, 512 MB

Once upon a time there was a strange shopkeeper. He used to buy things and sell them with the same amount of money that he bought. That means, he never made any profit or loss in his life with his business. One day, the shopkeeper put X number of Y dollar notes at the top of his desk and started talking with his customers. At that time, a thief was passing by the shop and noticed the notes. He secretly took all the notes from the desk and went away. The next day, the thief came to the shop again to buy some biscuits. The thief gave him the same amount of money that he stole yesterday. The shopkeeper gave him some biscuits and returned him the remaining Z dollar because the price of the biscuits was not greater than the amount he received. As a result, the shopkeeper made some losses for the first time in his life. Would you help us to calculate the loss amount?

This is a companion discussion topic for the original entry at