import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int m = Integer.parseInt(br.readLine());
        System.out.println(problem173a(m));
    }

    private static int problem173a(int n) {
        return ((n % 1000) == 0) ? 0 : (1000 - (n % 1000));
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int m = Integer.parseInt(br.readLine());
        System.out.println(problem173a(m));
    }

    private static int problem173a(int n) {
        return ((n % 1000) == 0) ? 0 : (1000 - (n % 1000));
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int m = Integer.parseInt(br.readLine());
        System.out.println(problem173a(m));
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int m = Integer.parseInt(br.readLine());
        System.out.println(problem173a(m));
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int m = Integer.parseInt(br.readLine()); m Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br System.out.println(problem173a(m)) System.out.println System.out System System.out problem173a(m) problem173a m String[] args args private static int problem173a(int n) {
        return ((n % 1000) == 0) ? 0 : (1000 - (n % 1000));
    } problem173a {
        return ((n % 1000) == 0) ? 0 : (1000 - (n % 1000));
    } return ((n % 1000) == 0) ? 0 : (1000 - (n % 1000)); ((n % 1000) == 0) ? 0 : (1000 - (n % 1000)) ((n % 1000) == 0) (n % 1000) n 1000 0 0 (1000 - (n % 1000)) 1000 (n % 1000) n 1000 int n n public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int m = Integer.parseInt(br.readLine());
        System.out.println(problem173a(m));
    }

    private static int problem173a(int n) {
        return ((n % 1000) == 0) ? 0 : (1000 - (n % 1000));
    }
} public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int m = Integer.parseInt(br.readLine());
        System.out.println(problem173a(m));
    }

    private static int problem173a(int n) {
        return ((n % 1000) == 0) ? 0 : (1000 - (n % 1000));
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int m = Integer.parseInt(br.readLine());
        System.out.println(problem173a(m));
    }

    private static int problem173a(int n) {
        return ((n % 1000) == 0) ? 0 : (1000 - (n % 1000));
    }
}