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