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