import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer price = sc.nextInt();
        Integer change = 0;

        if (price % 1000 == 0){
          Integer count_bill = (price / 1000);
          change = ((count_bill * 1000) - price); 
        }
        else{
          Integer count_bill = (price / 1000) + 1;
          change = ((count_bill * 1000) - price); 
        }
        
        System.out.println(change);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer price = sc.nextInt();
        Integer change = 0;

        if (price % 1000 == 0){
          Integer count_bill = (price / 1000);
          change = ((count_bill * 1000) - price); 
        }
        else{
          Integer count_bill = (price / 1000) + 1;
          change = ((count_bill * 1000) - price); 
        }
        
        System.out.println(change);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer price = sc.nextInt();
        Integer change = 0;

        if (price % 1000 == 0){
          Integer count_bill = (price / 1000);
          change = ((count_bill * 1000) - price); 
        }
        else{
          Integer count_bill = (price / 1000) + 1;
          change = ((count_bill * 1000) - price); 
        }
        
        System.out.println(change);
    } main {
        Scanner sc = new Scanner(System.in);
        Integer price = sc.nextInt();
        Integer change = 0;

        if (price % 1000 == 0){
          Integer count_bill = (price / 1000);
          change = ((count_bill * 1000) - price); 
        }
        else{
          Integer count_bill = (price / 1000) + 1;
          change = ((count_bill * 1000) - price); 
        }
        
        System.out.println(change);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Integer price = sc.nextInt(); price sc.nextInt() sc.nextInt sc Integer change = 0; change 0 if (price % 1000 == 0){
          Integer count_bill = (price / 1000);
          change = ((count_bill * 1000) - price); 
        }
        else{
          Integer count_bill = (price / 1000) + 1;
          change = ((count_bill * 1000) - price); 
        } price % 1000 == 0 price % 1000 price 1000 0 {
          Integer count_bill = (price / 1000);
          change = ((count_bill * 1000) - price); 
        } Integer count_bill = (price / 1000); count_bill (price / 1000) price 1000 change = ((count_bill * 1000) - price) change ((count_bill * 1000) - price) (count_bill * 1000) count_bill 1000 price {
          Integer count_bill = (price / 1000) + 1;
          change = ((count_bill * 1000) - price); 
        } Integer count_bill = (price / 1000) + 1; count_bill (price / 1000) + 1 (price / 1000) price 1000 1 change = ((count_bill * 1000) - price) change ((count_bill * 1000) - price) (count_bill * 1000) count_bill 1000 price System.out.println(change) System.out.println System.out System System.out change String[] args args
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer price = sc.nextInt();
        Integer change = 0;

        if (price % 1000 == 0){
          Integer count_bill = (price / 1000);
          change = ((count_bill * 1000) - price); 
        }
        else{
          Integer count_bill = (price / 1000) + 1;
          change = ((count_bill * 1000) - price); 
        }
        
        System.out.println(change);
    }
}