import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try(Scanner sc = new Scanner(System.in);){
            System.out.println(new Main().run(sc));
        }
    }
    
    private String run(Scanner sc){
        int n = Integer.parseInt(sc.next());
        while(n > 0){
            n -= 1000;
        }
        return Integer.toString(Math.abs(n));
    }
    
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        try(Scanner sc = new Scanner(System.in);){
            System.out.println(new Main().run(sc));
        }
    }
    
    private String run(Scanner sc){
        int n = Integer.parseInt(sc.next());
        while(n > 0){
            n -= 1000;
        }
        return Integer.toString(Math.abs(n));
    }
    
} Main public static void main(String[] args) throws Exception {
        try(Scanner sc = new Scanner(System.in);){
            System.out.println(new Main().run(sc));
        }
    } main {
        try(Scanner sc = new Scanner(System.in);){
            System.out.println(new Main().run(sc));
        }
    } try(Scanner sc = new Scanner(System.in);){
            System.out.println(new Main().run(sc));
        } {
            System.out.println(new Main().run(sc));
        } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) System.out.println(new Main().run(sc)) System.out.println System.out System System.out new Main().run(sc) new Main().run new Main() sc String[] args args private String run(Scanner sc){
        int n = Integer.parseInt(sc.next());
        while(n > 0){
            n -= 1000;
        }
        return Integer.toString(Math.abs(n));
    } run {
        int n = Integer.parseInt(sc.next());
        while(n > 0){
            n -= 1000;
        }
        return Integer.toString(Math.abs(n));
    } int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc while(n > 0){
            n -= 1000;
        } n > 0 n 0 {
            n -= 1000;
        } n -= 1000 n 1000 return Integer.toString(Math.abs(n)); Integer.toString(Math.abs(n)) Integer.toString Integer Math.abs(n) Math.abs Math n Scanner sc sc public class Main {
    public static void main(String[] args) throws Exception {
        try(Scanner sc = new Scanner(System.in);){
            System.out.println(new Main().run(sc));
        }
    }
    
    private String run(Scanner sc){
        int n = Integer.parseInt(sc.next());
        while(n > 0){
            n -= 1000;
        }
        return Integer.toString(Math.abs(n));
    }
    
} public class Main {
    public static void main(String[] args) throws Exception {
        try(Scanner sc = new Scanner(System.in);){
            System.out.println(new Main().run(sc));
        }
    }
    
    private String run(Scanner sc){
        int n = Integer.parseInt(sc.next());
        while(n > 0){
            n -= 1000;
        }
        return Integer.toString(Math.abs(n));
    }
    
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try(Scanner sc = new Scanner(System.in);){
            System.out.println(new Main().run(sc));
        }
    }
    
    private String run(Scanner sc){
        int n = Integer.parseInt(sc.next());
        while(n > 0){
            n -= 1000;
        }
        return Integer.toString(Math.abs(n));
    }
    
}
