import java.util.*;

class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner (System.in);
        
        int n = sc.nextInt();
        
        int moneyCount = 1;
        int money = 1000;
        
        while (money * moneyCount < n) {
            moneyCount++;
        }
        
        int result = money * moneyCount - n;
        
        System.out.println(result);
        
    }
} import java.util.*; util.* java class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner (System.in);
        
        int n = sc.nextInt();
        
        int moneyCount = 1;
        int money = 1000;
        
        while (money * moneyCount < n) {
            moneyCount++;
        }
        
        int result = money * moneyCount - n;
        
        System.out.println(result);
        
    }
} Main public static void main (String[] args)
    {
        Scanner sc = new Scanner (System.in);
        
        int n = sc.nextInt();
        
        int moneyCount = 1;
        int money = 1000;
        
        while (money * moneyCount < n) {
            moneyCount++;
        }
        
        int result = money * moneyCount - n;
        
        System.out.println(result);
        
    } main {
        Scanner sc = new Scanner (System.in);
        
        int n = sc.nextInt();
        
        int moneyCount = 1;
        int money = 1000;
        
        while (money * moneyCount < n) {
            moneyCount++;
        }
        
        int result = money * moneyCount - n;
        
        System.out.println(result);
        
    } Scanner sc = new Scanner (System.in); sc new Scanner (System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int moneyCount = 1; moneyCount 1 int money = 1000; money 1000 while (money * moneyCount < n) {
            moneyCount++;
        } money * moneyCount < n money * moneyCount money moneyCount n {
            moneyCount++;
        } moneyCount++ moneyCount int result = money * moneyCount - n; result money * moneyCount - n money * moneyCount money moneyCount n System.out.println(result) System.out.println System.out System System.out result 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 moneyCount = 1;
        int money = 1000;
        
        while (money * moneyCount < n) {
            moneyCount++;
        }
        
        int result = money * moneyCount - n;
        
        System.out.println(result);
        
    }
}