import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int num = Integer.valueOf(sc.nextInt());
    
    while(num > 0) {
      num = num - 1000;
    } 
    if (num != 0) {
      num = (-1) * num;
    }

    System.out.println(num);
    sc.close();
  }
} import java.util.*; util.* java class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int num = Integer.valueOf(sc.nextInt());
    
    while(num > 0) {
      num = num - 1000;
    } 
    if (num != 0) {
      num = (-1) * num;
    }

    System.out.println(num);
    sc.close();
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int num = Integer.valueOf(sc.nextInt());
    
    while(num > 0) {
      num = num - 1000;
    } 
    if (num != 0) {
      num = (-1) * num;
    }

    System.out.println(num);
    sc.close();
  } main {
    Scanner sc = new Scanner(System.in);
    int num = Integer.valueOf(sc.nextInt());
    
    while(num > 0) {
      num = num - 1000;
    } 
    if (num != 0) {
      num = (-1) * num;
    }

    System.out.println(num);
    sc.close();
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int num = Integer.valueOf(sc.nextInt()); num Integer.valueOf(sc.nextInt()) Integer.valueOf Integer sc.nextInt() sc.nextInt sc while(num > 0) {
      num = num - 1000;
    } num > 0 num 0 {
      num = num - 1000;
    } num = num - 1000 num num - 1000 num 1000 if (num != 0) {
      num = (-1) * num;
    } num != 0 num 0 {
      num = (-1) * num;
    } num = (-1) * num num (-1) * num (-1) 1 num System.out.println(num) System.out.println System.out System System.out num sc.close() sc.close sc String[] args args
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int num = Integer.valueOf(sc.nextInt());
    
    while(num > 0) {
      num = num - 1000;
    } 
    if (num != 0) {
      num = (-1) * num;
    }

    System.out.println(num);
    sc.close();
  }
}