import java.util.*;
import java.lang.*;

public class Main
{
    public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        System.out.println((1000-t%1000)%1000);
    }
} import java.util.*; util.* java import java.lang.*; lang.* java public class Main
{
    public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        System.out.println((1000-t%1000)%1000);
    }
} Main public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        System.out.println((1000-t%1000)%1000);
    } main {
        // your code goes here
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        System.out.println((1000-t%1000)%1000);
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int t = s.nextInt(); t s.nextInt() s.nextInt s System.out.println((1000-t%1000)%1000) System.out.println System.out System System.out (1000-t%1000)%1000 (1000-t%1000) 1000 t%1000 t 1000 1000 String[] args args public class Main
{
    public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        System.out.println((1000-t%1000)%1000);
    }
} public class Main
{
    public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        System.out.println((1000-t%1000)%1000);
    }
} Main
import java.util.*;
import java.lang.*;

public class Main
{
    public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        System.out.println((1000-t%1000)%1000);
    }
}
