program main
	implicit none
	integer :: N, S, i
		read(*,*) N
		S=1000
		if(N<1000)	then
			write(*,*) N
		else if(1000<=N .and. N<2000) then
			write(*,*) S*2-N
		else if(2000<=N .and. N<3000) then
			write(*,*) S*3-N
		else if(3000<=N .and. N<4000) then
			write(*,*) S*4-N
		else if(4000<=N .and. N<5000) then
			write(*,*) S*5-N
		else if(5000<=N .and. N<6000) then
			write(*,*) S*6-N
		else if(6000<=N .and. N<7000) then
			write(*,*) S*7-N
		else if(7000<=N .and. N<8000) then
			write(*,*) S*8-N
		else if(8000<=N .and. N<9000) then
			write(*,*) S*9-N
		else if(9000<=N .and. N<=10000) then
			write(*,*) S*10-N
		endif
end program main