calculating shortage and surplus - Search