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