
import java.util.ArrayList;
import java.util.Scanner;


public class Main {
public static void main (String[] args){


	Scanner sc =new Scanner(System.in);
	ArrayList<Integer> list=new ArrayList<Integer>();


	while(sc.hasNextLine()) {
		list.add(Integer.parseInt(sc.nextLine()));
	}
	
	int thousand=list.get(0)/1000;
	
	if(list.get(0)%1000!=0) {
	int thousands=(int) Math.floor(thousand)+1;

	System.out.print(thousands*1000-list.get(0));
	}else {
		System.out.print(0);
	}
}}

 import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
public static void main (String[] args){


	Scanner sc =new Scanner(System.in);
	ArrayList<Integer> list=new ArrayList<Integer>();


	while(sc.hasNextLine()) {
		list.add(Integer.parseInt(sc.nextLine()));
	}
	
	int thousand=list.get(0)/1000;
	
	if(list.get(0)%1000!=0) {
	int thousands=(int) Math.floor(thousand)+1;

	System.out.print(thousands*1000-list.get(0));
	}else {
		System.out.print(0);
	}
}} Main public static void main (String[] args){


	Scanner sc =new Scanner(System.in);
	ArrayList<Integer> list=new ArrayList<Integer>();


	while(sc.hasNextLine()) {
		list.add(Integer.parseInt(sc.nextLine()));
	}
	
	int thousand=list.get(0)/1000;
	
	if(list.get(0)%1000!=0) {
	int thousands=(int) Math.floor(thousand)+1;

	System.out.print(thousands*1000-list.get(0));
	}else {
		System.out.print(0);
	}
} main {


	Scanner sc =new Scanner(System.in);
	ArrayList<Integer> list=new ArrayList<Integer>();


	while(sc.hasNextLine()) {
		list.add(Integer.parseInt(sc.nextLine()));
	}
	
	int thousand=list.get(0)/1000;
	
	if(list.get(0)%1000!=0) {
	int thousands=(int) Math.floor(thousand)+1;

	System.out.print(thousands*1000-list.get(0));
	}else {
		System.out.print(0);
	}
} Scanner sc =new Scanner(System.in); sc new Scanner(System.in) ArrayList<Integer> list=new ArrayList<Integer>(); list new ArrayList<Integer>() while(sc.hasNextLine()) {
		list.add(Integer.parseInt(sc.nextLine()));
	} sc.hasNextLine() sc.hasNextLine sc {
		list.add(Integer.parseInt(sc.nextLine()));
	} list.add(Integer.parseInt(sc.nextLine())) list.add list Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc int thousand=list.get(0)/1000; thousand list.get(0)/1000 list.get(0) list.get list 0 1000 if(list.get(0)%1000!=0) {
	int thousands=(int) Math.floor(thousand)+1;

	System.out.print(thousands*1000-list.get(0));
	}else {
		System.out.print(0);
	} list.get(0)%1000!=0 list.get(0)%1000 list.get(0) list.get list 0 1000 0 {
	int thousands=(int) Math.floor(thousand)+1;

	System.out.print(thousands*1000-list.get(0));
	} int thousands=(int) Math.floor(thousand)+1; thousands (int) Math.floor(thousand)+1 (int) Math.floor(thousand) Math.floor Math thousand 1 System.out.print(thousands*1000-list.get(0)) System.out.print System.out System System.out thousands*1000-list.get(0) thousands*1000 thousands 1000 list.get(0) list.get list 0 {
		System.out.print(0);
	} System.out.print(0) System.out.print System.out System System.out 0 String[] args args public class Main {
public static void main (String[] args){


	Scanner sc =new Scanner(System.in);
	ArrayList<Integer> list=new ArrayList<Integer>();


	while(sc.hasNextLine()) {
		list.add(Integer.parseInt(sc.nextLine()));
	}
	
	int thousand=list.get(0)/1000;
	
	if(list.get(0)%1000!=0) {
	int thousands=(int) Math.floor(thousand)+1;

	System.out.print(thousands*1000-list.get(0));
	}else {
		System.out.print(0);
	}
}} public class Main {
public static void main (String[] args){


	Scanner sc =new Scanner(System.in);
	ArrayList<Integer> list=new ArrayList<Integer>();


	while(sc.hasNextLine()) {
		list.add(Integer.parseInt(sc.nextLine()));
	}
	
	int thousand=list.get(0)/1000;
	
	if(list.get(0)%1000!=0) {
	int thousands=(int) Math.floor(thousand)+1;

	System.out.print(thousands*1000-list.get(0));
	}else {
		System.out.print(0);
	}
}} Main

import java.util.ArrayList;
import java.util.Scanner;


public class Main {
public static void main (String[] args){


	Scanner sc =new Scanner(System.in);
	ArrayList<Integer> list=new ArrayList<Integer>();


	while(sc.hasNextLine()) {
		list.add(Integer.parseInt(sc.nextLine()));
	}
	
	int thousand=list.get(0)/1000;
	
	if(list.get(0)%1000!=0) {
	int thousands=(int) Math.floor(thousand)+1;

	System.out.print(thousands*1000-list.get(0));
	}else {
		System.out.print(0);
	}
}}


