import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println((10000-n)%1000);
    }
}

class Monmo {
    
}
 import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println((10000-n)%1000);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println((10000-n)%1000);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println((10000-n)%1000);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc System.out.println((10000-n)%1000) System.out.println System.out System System.out (10000-n)%1000 (10000-n) 10000 n 1000 String[] args args class Monmo {
    
} Monmo public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println((10000-n)%1000);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println((10000-n)%1000);
    }
} Main
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println((10000-n)%1000);
    }
}

class Monmo {
    
}

