import java.util.*;
public class Main{
public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
   int r=0;;
int low = 1000;
int m = n%low;
if(m==0){
    System.out.println(0);
}else{
 r = 1000-m;
 System.out.println(r);
}


}
} import java.util.*; util.* java public class Main{
public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
   int r=0;;
int low = 1000;
int m = n%low;
if(m==0){
    System.out.println(0);
}else{
 r = 1000-m;
 System.out.println(r);
}


}
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
   int r=0;;
int low = 1000;
int m = n%low;
if(m==0){
    System.out.println(0);
}else{
 r = 1000-m;
 System.out.println(r);
}


} main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
   int r=0;;
int low = 1000;
int m = n%low;
if(m==0){
    System.out.println(0);
}else{
 r = 1000-m;
 System.out.println(r);
}


} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int r=0; r 0 int low = 1000; low 1000 int m = n%low; m n%low n low if(m==0){
    System.out.println(0);
}else{
 r = 1000-m;
 System.out.println(r);
} m==0 m 0 {
    System.out.println(0);
} System.out.println(0) System.out.println System.out System System.out 0 {
 r = 1000-m;
 System.out.println(r);
} r = 1000-m r 1000-m 1000 m System.out.println(r) System.out.println System.out System System.out r String[] args args public class Main{
public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
   int r=0;;
int low = 1000;
int m = n%low;
if(m==0){
    System.out.println(0);
}else{
 r = 1000-m;
 System.out.println(r);
}


}
} public class Main{
public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
   int r=0;;
int low = 1000;
int m = n%low;
if(m==0){
    System.out.println(0);
}else{
 r = 1000-m;
 System.out.println(r);
}


}
} Main
import java.util.*;
public class Main{
public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
   int r=0;;
int low = 1000;
int m = n%low;
if(m==0){
    System.out.println(0);
}else{
 r = 1000-m;
 System.out.println(r);
}


}
}