import java.util.*;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int counter = 0;
        for(int i = 0; i < 10001; i ++){
                if(i - N >= 0){
                    counter = i - N;
                    System.out.println(counter);
                    break;
                }else{
                    i = i + 999;
                }
            }
    }
} import java.util.*; util.* java import java.lang.Math; Math java.lang public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int counter = 0;
        for(int i = 0; i < 10001; i ++){
                if(i - N >= 0){
                    counter = i - N;
                    System.out.println(counter);
                    break;
                }else{
                    i = i + 999;
                }
            }
    }
} Main public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int counter = 0;
        for(int i = 0; i < 10001; i ++){
                if(i - N >= 0){
                    counter = i - N;
                    System.out.println(counter);
                    break;
                }else{
                    i = i + 999;
                }
            }
    } main {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int counter = 0;
        for(int i = 0; i < 10001; i ++){
                if(i - N >= 0){
                    counter = i - N;
                    System.out.println(counter);
                    break;
                }else{
                    i = i + 999;
                }
            }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int counter = 0; counter 0 for(int i = 0; i < 10001; i ++){
                if(i - N >= 0){
                    counter = i - N;
                    System.out.println(counter);
                    break;
                }else{
                    i = i + 999;
                }
            } int i = 0; int i = 0; i 0 i < 10001 i 10001 i ++ i ++ i {
                if(i - N >= 0){
                    counter = i - N;
                    System.out.println(counter);
                    break;
                }else{
                    i = i + 999;
                }
            } {
                if(i - N >= 0){
                    counter = i - N;
                    System.out.println(counter);
                    break;
                }else{
                    i = i + 999;
                }
            } if(i - N >= 0){
                    counter = i - N;
                    System.out.println(counter);
                    break;
                }else{
                    i = i + 999;
                } i - N >= 0 i - N i N 0 {
                    counter = i - N;
                    System.out.println(counter);
                    break;
                } counter = i - N counter i - N i N System.out.println(counter) System.out.println System.out System System.out counter break; {
                    i = i + 999;
                } i = i + 999 i i + 999 i 999 String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int counter = 0;
        for(int i = 0; i < 10001; i ++){
                if(i - N >= 0){
                    counter = i - N;
                    System.out.println(counter);
                    break;
                }else{
                    i = i + 999;
                }
            }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int counter = 0;
        for(int i = 0; i < 10001; i ++){
                if(i - N >= 0){
                    counter = i - N;
                    System.out.println(counter);
                    break;
                }else{
                    i = i + 999;
                }
            }
    }
} Main
import java.util.*;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int counter = 0;
        for(int i = 0; i < 10001; i ++){
                if(i - N >= 0){
                    counter = i - N;
                    System.out.println(counter);
                    break;
                }else{
                    i = i + 999;
                }
            }
    }
}
