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

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

        }
    }
} Main public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        for(int i=1;i<=10;i++)
        {
            if(n<=i*1000)
            {
               System.out.println((i*1000)-n);
               break;
            }

        }
    } main {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        for(int i=1;i<=10;i++)
        {
            if(n<=i*1000)
            {
               System.out.println((i*1000)-n);
               break;
            }

        }
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc for(int i=1;i<=10;i++)
        {
            if(n<=i*1000)
            {
               System.out.println((i*1000)-n);
               break;
            }

        } int i=1; int i=1; i 1 i<=10 i 10 i++ i++ i {
            if(n<=i*1000)
            {
               System.out.println((i*1000)-n);
               break;
            }

        } {
            if(n<=i*1000)
            {
               System.out.println((i*1000)-n);
               break;
            }

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

        }
    }
}