
import java.util.*;
import java.io.*;

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int bill = 1000;

        if (N%bill==0)
        {
            System.out.println(0);

        }
        else
            {
          int no_of_notes = N/bill+1;
          System.out.println(no_of_notes*1000-N);
        }

            }
    } import java.util.*; util.* java import java.io.*; io.* java import static java.lang.Character.isUpperCase; import static java.lang.Character.isUpperCase; import static java.lang.Character.isUpperCase; public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int bill = 1000;

        if (N%bill==0)
        {
            System.out.println(0);

        }
        else
            {
          int no_of_notes = N/bill+1;
          System.out.println(no_of_notes*1000-N);
        }

            }
    } Main public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int bill = 1000;

        if (N%bill==0)
        {
            System.out.println(0);

        }
        else
            {
          int no_of_notes = N/bill+1;
          System.out.println(no_of_notes*1000-N);
        }

            } main {

        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int bill = 1000;

        if (N%bill==0)
        {
            System.out.println(0);

        }
        else
            {
          int no_of_notes = N/bill+1;
          System.out.println(no_of_notes*1000-N);
        }

            } Scanner in = new Scanner(System.in); in new Scanner(System.in) int N = in.nextInt(); N in.nextInt() in.nextInt in int bill = 1000; bill 1000 if (N%bill==0)
        {
            System.out.println(0);

        }
        else
            {
          int no_of_notes = N/bill+1;
          System.out.println(no_of_notes*1000-N);
        } N%bill==0 N%bill N bill 0 {
            System.out.println(0);

        } System.out.println(0) System.out.println System.out System System.out 0 {
          int no_of_notes = N/bill+1;
          System.out.println(no_of_notes*1000-N);
        } int no_of_notes = N/bill+1; no_of_notes N/bill+1 N/bill N bill 1 System.out.println(no_of_notes*1000-N) System.out.println System.out System System.out no_of_notes*1000-N no_of_notes*1000 no_of_notes 1000 N String[] args args public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int bill = 1000;

        if (N%bill==0)
        {
            System.out.println(0);

        }
        else
            {
          int no_of_notes = N/bill+1;
          System.out.println(no_of_notes*1000-N);
        }

            }
    } public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int bill = 1000;

        if (N%bill==0)
        {
            System.out.println(0);

        }
        else
            {
          int no_of_notes = N/bill+1;
          System.out.println(no_of_notes*1000-N);
        }

            }
    } Main

import java.util.*;
import java.io.*;

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int bill = 1000;

        if (N%bill==0)
        {
            System.out.println(0);

        }
        else
            {
          int no_of_notes = N/bill+1;
          System.out.println(no_of_notes*1000-N);
        }

            }
    }