import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!

        Scanner sc = new Scanner (System.in);
        
        int a = sc.nextInt();
        int b=a;
        int c =0;
        //6900
        while(true){
            if(a-1000>0){
                c++;
                a-=1000;
                
            }else if (a==0){
                System.out.println(c*1000);
                break;
            }//elseif
            else if(a-1000<=0){
          
                System.out.println((((++c)*1000))-b);
                break;
            }//elseif
        }//while
        
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!

        Scanner sc = new Scanner (System.in);
        
        int a = sc.nextInt();
        int b=a;
        int c =0;
        //6900
        while(true){
            if(a-1000>0){
                c++;
                a-=1000;
                
            }else if (a==0){
                System.out.println(c*1000);
                break;
            }//elseif
            else if(a-1000<=0){
          
                System.out.println((((++c)*1000))-b);
                break;
            }//elseif
        }//while
        
    }
} Main public static void main(String[] args) throws Exception {
        // Your code here!

        Scanner sc = new Scanner (System.in);
        
        int a = sc.nextInt();
        int b=a;
        int c =0;
        //6900
        while(true){
            if(a-1000>0){
                c++;
                a-=1000;
                
            }else if (a==0){
                System.out.println(c*1000);
                break;
            }//elseif
            else if(a-1000<=0){
          
                System.out.println((((++c)*1000))-b);
                break;
            }//elseif
        }//while
        
    } main {
        // Your code here!

        Scanner sc = new Scanner (System.in);
        
        int a = sc.nextInt();
        int b=a;
        int c =0;
        //6900
        while(true){
            if(a-1000>0){
                c++;
                a-=1000;
                
            }else if (a==0){
                System.out.println(c*1000);
                break;
            }//elseif
            else if(a-1000<=0){
          
                System.out.println((((++c)*1000))-b);
                break;
            }//elseif
        }//while
        
    } Scanner sc = new Scanner (System.in); sc new Scanner (System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b=a; b a int c =0; c 0 while(true){
            if(a-1000>0){
                c++;
                a-=1000;
                
            }else if (a==0){
                System.out.println(c*1000);
                break;
            }//elseif
            else if(a-1000<=0){
          
                System.out.println((((++c)*1000))-b);
                break;
            }//elseif
        }//while true {
            if(a-1000>0){
                c++;
                a-=1000;
                
            }else if (a==0){
                System.out.println(c*1000);
                break;
            }//elseif
            else if(a-1000<=0){
          
                System.out.println((((++c)*1000))-b);
                break;
            }//elseif
        } if(a-1000>0){
                c++;
                a-=1000;
                
            }else if (a==0){
                System.out.println(c*1000);
                break;
            }//elseif
            else if(a-1000<=0){
          
                System.out.println((((++c)*1000))-b);
                break;
            }//elseif a-1000>0 a-1000 a 1000 0 {
                c++;
                a-=1000;
                
            } c++ c a-=1000 a 1000 if (a==0){
                System.out.println(c*1000);
                break;
            }//elseif
            else if(a-1000<=0){
          
                System.out.println((((++c)*1000))-b);
                break;
            }//elseif a==0 a 0 {
                System.out.println(c*1000);
                break;
            } System.out.println(c*1000) System.out.println System.out System System.out c*1000 c 1000 break; if(a-1000<=0){
          
                System.out.println((((++c)*1000))-b);
                break;
            }//elseif a-1000<=0 a-1000 a 1000 0 {
          
                System.out.println((((++c)*1000))-b);
                break;
            } System.out.println((((++c)*1000))-b) System.out.println System.out System System.out (((++c)*1000))-b (((++c)*1000)) (++c) c 1000 b break; String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!

        Scanner sc = new Scanner (System.in);
        
        int a = sc.nextInt();
        int b=a;
        int c =0;
        //6900
        while(true){
            if(a-1000>0){
                c++;
                a-=1000;
                
            }else if (a==0){
                System.out.println(c*1000);
                break;
            }//elseif
            else if(a-1000<=0){
          
                System.out.println((((++c)*1000))-b);
                break;
            }//elseif
        }//while
        
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!

        Scanner sc = new Scanner (System.in);
        
        int a = sc.nextInt();
        int b=a;
        int c =0;
        //6900
        while(true){
            if(a-1000>0){
                c++;
                a-=1000;
                
            }else if (a==0){
                System.out.println(c*1000);
                break;
            }//elseif
            else if(a-1000<=0){
          
                System.out.println((((++c)*1000))-b);
                break;
            }//elseif
        }//while
        
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!

        Scanner sc = new Scanner (System.in);
        
        int a = sc.nextInt();
        int b=a;
        int c =0;
        //6900
        while(true){
            if(a-1000>0){
                c++;
                a-=1000;
                
            }else if (a==0){
                System.out.println(c*1000);
                break;
            }//elseif
            else if(a-1000<=0){
          
                System.out.println((((++c)*1000))-b);
                break;
            }//elseif
        }//while
        
    }
}
