
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = 1;
        long p = 1000 * a;
        if(p>=n){
            System.out.println(p-n);
        }
        while(n > p){
            a++;
            p = 1000*a;
            if(p>=n){
                System.out.println(p-n);
                break;
            }
            
        }
    }
}


 import java.util.Scanner; Scanner java.util class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = 1;
        long p = 1000 * a;
        if(p>=n){
            System.out.println(p-n);
        }
        while(n > p){
            a++;
            p = 1000*a;
            if(p>=n){
                System.out.println(p-n);
                break;
            }
            
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = 1;
        long p = 1000 * a;
        if(p>=n){
            System.out.println(p-n);
        }
        while(n > p){
            a++;
            p = 1000*a;
            if(p>=n){
                System.out.println(p-n);
                break;
            }
            
        }
    } main {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = 1;
        long p = 1000 * a;
        if(p>=n){
            System.out.println(p-n);
        }
        while(n > p){
            a++;
            p = 1000*a;
            if(p>=n){
                System.out.println(p-n);
                break;
            }
            
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long n = sc.nextLong(); n sc.nextLong() sc.nextLong sc long a = 1; a 1 long p = 1000 * a; p 1000 * a 1000 a if(p>=n){
            System.out.println(p-n);
        } p>=n p n {
            System.out.println(p-n);
        } System.out.println(p-n) System.out.println System.out System System.out p-n p n while(n > p){
            a++;
            p = 1000*a;
            if(p>=n){
                System.out.println(p-n);
                break;
            }
            
        } n > p n p {
            a++;
            p = 1000*a;
            if(p>=n){
                System.out.println(p-n);
                break;
            }
            
        } a++ a p = 1000*a p 1000*a 1000 a if(p>=n){
                System.out.println(p-n);
                break;
            } p>=n p n {
                System.out.println(p-n);
                break;
            } System.out.println(p-n) System.out.println System.out System System.out p-n p n break; String[] args args

import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = 1;
        long p = 1000 * a;
        if(p>=n){
            System.out.println(p-n);
        }
        while(n > p){
            a++;
            p = 1000*a;
            if(p>=n){
                System.out.println(p-n);
                break;
            }
            
        }
    }
}



