import java.util.*;

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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int payment = sc.nextInt();
    if (payment % 1000 == 0) {
      System.out.println(0);
    } else {
      int charge = 1000 - (payment % 1000);
      System.out.println(charge);
    }
  }
}
