how should i write the VHDL codes for a counter that does a up count for the first input, down count for the second input, up count for the third input and so on ??
The description is not clear.
I guess that at each input pulse the operating mode of the counter toggles between up and down.
So you need (guess what) a toggle flip-flop whose output is the OPERATING_MODE signal - used to control the counter operations.