import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
      	int ret = -1;
      	int cnt = 1;
      	while(ret <= -1){
          ret = cnt*1000 - a;
          cnt++;
        }
		
      	System.out.println(ret);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
      	int ret = -1;
      	int cnt = 1;
      	while(ret <= -1){
          ret = cnt*1000 - a;
          cnt++;
        }
		
      	System.out.println(ret);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
      	int ret = -1;
      	int cnt = 1;
      	while(ret <= -1){
          ret = cnt*1000 - a;
          cnt++;
        }
		
      	System.out.println(ret);
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
      	int ret = -1;
      	int cnt = 1;
      	while(ret <= -1){
          ret = cnt*1000 - a;
          cnt++;
        }
		
      	System.out.println(ret);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int ret = -1; ret -1 1 int cnt = 1; cnt 1 while(ret <= -1){
          ret = cnt*1000 - a;
          cnt++;
        } ret <= -1 ret -1 1 {
          ret = cnt*1000 - a;
          cnt++;
        } ret = cnt*1000 - a ret cnt*1000 - a cnt*1000 cnt 1000 a cnt++ cnt System.out.println(ret) System.out.println System.out System System.out ret String[] args args
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
      	int ret = -1;
      	int cnt = 1;
      	while(ret <= -1){
          ret = cnt*1000 - a;
          cnt++;
        }
		
      	System.out.println(ret);
    }
}