import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
       int cash = 1000;
       int count = 1;
        while (cash * count < n) {
            count++;
        }
        
        int payment = cash * count - n;
        System.out.println(payment);
    }
}
             import java.util.*; util.* java class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
       int cash = 1000;
       int count = 1;
        while (cash * count < n) {
            count++;
        }
        
        int payment = cash * count - n;
        System.out.println(payment);
    }
} Main public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
       int cash = 1000;
       int count = 1;
        while (cash * count < n) {
            count++;
        }
        
        int payment = cash * count - n;
        System.out.println(payment);
    } main {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
       int cash = 1000;
       int count = 1;
        while (cash * count < n) {
            count++;
        }
        
        int payment = cash * count - n;
        System.out.println(payment);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int cash = 1000; cash 1000 int count = 1; count 1 while (cash * count < n) {
            count++;
        } cash * count < n cash * count cash count n {
            count++;
        } count++ count int payment = cash * count - n; payment cash * count - n cash * count cash count n System.out.println(payment) System.out.println System.out System System.out payment String[] args args
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
       int cash = 1000;
       int count = 1;
        while (cash * count < n) {
            count++;
        }
        
        int payment = cash * count - n;
        System.out.println(payment);
    }
}
            