import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    if(n%1000==0)
    {
      System.out.println("0");
    }
    else
    {
      int a=(n/1000)+1;
      System.out.println((a*1000)-n);
    }
  }
} import java.util.*; util.* java public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    if(n%1000==0)
    {
      System.out.println("0");
    }
    else
    {
      int a=(n/1000)+1;
      System.out.println((a*1000)-n);
    }
  }
} Main public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    if(n%1000==0)
    {
      System.out.println("0");
    }
    else
    {
      int a=(n/1000)+1;
      System.out.println((a*1000)-n);
    }
  } main {
    Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    if(n%1000==0)
    {
      System.out.println("0");
    }
    else
    {
      int a=(n/1000)+1;
      System.out.println((a*1000)-n);
    }
  } Scanner in=new Scanner(System.in); in new Scanner(System.in) int n=in.nextInt(); n in.nextInt() in.nextInt in if(n%1000==0)
    {
      System.out.println("0");
    }
    else
    {
      int a=(n/1000)+1;
      System.out.println((a*1000)-n);
    } n%1000==0 n%1000 n 1000 0 {
      System.out.println("0");
    } System.out.println("0") System.out.println System.out System System.out "0" {
      int a=(n/1000)+1;
      System.out.println((a*1000)-n);
    } int a=(n/1000)+1; a (n/1000)+1 (n/1000) n 1000 1 System.out.println((a*1000)-n) System.out.println System.out System System.out (a*1000)-n (a*1000) a 1000 n String args[] args public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    if(n%1000==0)
    {
      System.out.println("0");
    }
    else
    {
      int a=(n/1000)+1;
      System.out.println((a*1000)-n);
    }
  }
} public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    if(n%1000==0)
    {
      System.out.println("0");
    }
    else
    {
      int a=(n/1000)+1;
      System.out.println((a*1000)-n);
    }
  }
} Main
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    if(n%1000==0)
    {
      System.out.println("0");
    }
    else
    {
      int a=(n/1000)+1;
      System.out.println((a*1000)-n);
    }
  }
}