A person went to a shop with a certain sum of money. There he borrowed as much as he had with him, spent Rs. 2 out of the whole, with the remainder he went to a second shop where he borrowed as much as he was left with and again spent Rs. 2. He then went to a third shop borrowing and spending as before, after which he was left with nothing. How much money did he borrow in all?