import java.util.*; 
class Main 
{
public static void main(String args[]) 
{
Scanner sc = new Scanner(System.in); 
int n = sc.nextInt(); 
int value = 1000;


while(value<n)
{
value=value+1000;
}  

System.out.print(value-n);
} 
} import java.util.*; util.* java class Main 
{
public static void main(String args[]) 
{
Scanner sc = new Scanner(System.in); 
int n = sc.nextInt(); 
int value = 1000;


while(value<n)
{
value=value+1000;
}  

System.out.print(value-n);
} 
} Main public static void main(String args[]) 
{
Scanner sc = new Scanner(System.in); 
int n = sc.nextInt(); 
int value = 1000;


while(value<n)
{
value=value+1000;
}  

System.out.print(value-n);
} main {
Scanner sc = new Scanner(System.in); 
int n = sc.nextInt(); 
int value = 1000;


while(value<n)
{
value=value+1000;
}  

System.out.print(value-n);
} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int value = 1000; value 1000 while(value<n)
{
value=value+1000;
} value<n value n {
value=value+1000;
} value=value+1000 value value+1000 value 1000 System.out.print(value-n) System.out.print System.out System System.out value-n value n String args[] args
import java.util.*; 
class Main 
{
public static void main(String args[]) 
{
Scanner sc = new Scanner(System.in); 
int n = sc.nextInt(); 
int value = 1000;


while(value<n)
{
value=value+1000;
}  

System.out.print(value-n);
} 
}