import java.util.*;
public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int i = 1000;
    while (N > 0) {
    	N -= i;
    }
    System.out.println(Math.abs(N));
  }
} import java.util.*; util.* java public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int i = 1000;
    while (N > 0) {
    	N -= i;
    }
    System.out.println(Math.abs(N));
  }
} Main public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int i = 1000;
    while (N > 0) {
    	N -= i;
    }
    System.out.println(Math.abs(N));
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int i = 1000;
    while (N > 0) {
    	N -= i;
    }
    System.out.println(Math.abs(N));
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int i = 1000; i 1000 while (N > 0) {
    	N -= i;
    } N > 0 N 0 {
    	N -= i;
    } N -= i N i System.out.println(Math.abs(N)) System.out.println System.out System System.out Math.abs(N) Math.abs Math N String[] args args public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int i = 1000;
    while (N > 0) {
    	N -= i;
    }
    System.out.println(Math.abs(N));
  }
} public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int i = 1000;
    while (N > 0) {
    	N -= i;
    }
    System.out.println(Math.abs(N));
  }
} Main
import java.util.*;
public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int i = 1000;
    while (N > 0) {
    	N -= i;
    }
    System.out.println(Math.abs(N));
  }
}