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