import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();

    for(int i = 0; i < 11 ; i++){
        if(1000 * i >= n){
            System.out.println(1000*i - n);
            System.exit(0);
        }
    }




    





    
    


    
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.*; io.* java import java.util.*; util.* java import java.util.ArrayList; ArrayList java.util import java.util.Iterator; Iterator java.util import java.util.List; List java.util import java.util.Collections; Collections java.util import java.util.Arrays; Arrays java.util public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();

    for(int i = 0; i < 11 ; i++){
        if(1000 * i >= n){
            System.out.println(1000*i - n);
            System.exit(0);
        }
    }




    





    
    


    
	}
} Main public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();

    for(int i = 0; i < 11 ; i++){
        if(1000 * i >= n){
            System.out.println(1000*i - n);
            System.exit(0);
        }
    }




    





    
    


    
	} main {
    
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();

    for(int i = 0; i < 11 ; i++){
        if(1000 * i >= n){
            System.out.println(1000*i - n);
            System.exit(0);
        }
    }




    





    
    


    
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc for(int i = 0; i < 11 ; i++){
        if(1000 * i >= n){
            System.out.println(1000*i - n);
            System.exit(0);
        }
    } int i = 0; int i = 0; i 0 i < 11 i 11 i++ i++ i {
        if(1000 * i >= n){
            System.out.println(1000*i - n);
            System.exit(0);
        }
    } {
        if(1000 * i >= n){
            System.out.println(1000*i - n);
            System.exit(0);
        }
    } if(1000 * i >= n){
            System.out.println(1000*i - n);
            System.exit(0);
        } 1000 * i >= n 1000 * i 1000 i n {
            System.out.println(1000*i - n);
            System.exit(0);
        } System.out.println(1000*i - n) System.out.println System.out System System.out 1000*i - n 1000*i 1000 i n System.exit(0) System.exit System 0 final String[] args args public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();

    for(int i = 0; i < 11 ; i++){
        if(1000 * i >= n){
            System.out.println(1000*i - n);
            System.exit(0);
        }
    }




    





    
    


    
	}
} public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();

    for(int i = 0; i < 11 ; i++){
        if(1000 * i >= n){
            System.out.println(1000*i - n);
            System.exit(0);
        }
    }




    





    
    


    
	}
} Main
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();

    for(int i = 0; i < 11 ; i++){
        if(1000 * i >= n){
            System.out.println(1000*i - n);
            System.exit(0);
        }
    }




    





    
    


    
	}
}