import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int price = sc.nextInt();
        
        if(1000 >= price) {
            System.out.println(1000 - price);
        } else {
            int surplus = price % 1000;
            int change  = 0;
            if(0 != surplus) {
                change = 1000 - surplus;
            }
            System.out.println(change);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int price = sc.nextInt();
        
        if(1000 >= price) {
            System.out.println(1000 - price);
        } else {
            int surplus = price % 1000;
            int change  = 0;
            if(0 != surplus) {
                change = 1000 - surplus;
            }
            System.out.println(change);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int price = sc.nextInt();
        
        if(1000 >= price) {
            System.out.println(1000 - price);
        } else {
            int surplus = price % 1000;
            int change  = 0;
            if(0 != surplus) {
                change = 1000 - surplus;
            }
            System.out.println(change);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int price = sc.nextInt();
        
        if(1000 >= price) {
            System.out.println(1000 - price);
        } else {
            int surplus = price % 1000;
            int change  = 0;
            if(0 != surplus) {
                change = 1000 - surplus;
            }
            System.out.println(change);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int price = sc.nextInt(); price sc.nextInt() sc.nextInt sc if(1000 >= price) {
            System.out.println(1000 - price);
        } else {
            int surplus = price % 1000;
            int change  = 0;
            if(0 != surplus) {
                change = 1000 - surplus;
            }
            System.out.println(change);
        } 1000 >= price 1000 price {
            System.out.println(1000 - price);
        } System.out.println(1000 - price) System.out.println System.out System System.out 1000 - price 1000 price {
            int surplus = price % 1000;
            int change  = 0;
            if(0 != surplus) {
                change = 1000 - surplus;
            }
            System.out.println(change);
        } int surplus = price % 1000; surplus price % 1000 price 1000 int change  = 0; change 0 if(0 != surplus) {
                change = 1000 - surplus;
            } 0 != surplus 0 surplus {
                change = 1000 - surplus;
            } change = 1000 - surplus change 1000 - surplus 1000 surplus System.out.println(change) System.out.println System.out System System.out change String[] args args public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int price = sc.nextInt();
        
        if(1000 >= price) {
            System.out.println(1000 - price);
        } else {
            int surplus = price % 1000;
            int change  = 0;
            if(0 != surplus) {
                change = 1000 - surplus;
            }
            System.out.println(change);
        }
    }
} public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int price = sc.nextInt();
        
        if(1000 >= price) {
            System.out.println(1000 - price);
        } else {
            int surplus = price % 1000;
            int change  = 0;
            if(0 != surplus) {
                change = 1000 - surplus;
            }
            System.out.println(change);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int price = sc.nextInt();
        
        if(1000 >= price) {
            System.out.println(1000 - price);
        } else {
            int surplus = price % 1000;
            int change  = 0;
            if(0 != surplus) {
                change = 1000 - surplus;
            }
            System.out.println(change);
        }
    }
}