//SHIVAM GARG
import java.util.*;
import java.lang.*;
import java.io.*;
 
/*
2
2
5 9
7
1 2 4 8 16 64 128
*/
public class Main
{
 
 
	public static void main (String[] args) throws java.lang.Exception {
	    FastReader reader = new FastReader();
	    int temp = reader.nextInt() % 1000;
		if(temp  == 0){
                System.out.println(0);
        }else{
                          System.out.println(1000-temp);
        }

			    
    }
    
 
 
 /* Iterative Function to calculate  (x^y)%p in O(log y) */
 
    public static long prime = 1000000007;
    public static long[] fact;
    static long power(long x, long y) 
    { 
        // Initialize result 
        long res = 1; 
        // Update x if it is more than or 
        // equal to p 
        x = x % prime; 
                      
        while (y > 0) 
        { 
            // If y is odd, multiply x  with result 
            if (y % 2 == 1) 
                res = (res * x) % prime; 
            // y must be even now 
            y = y >> 1; // y = y/2 
            x = (x * x) % prime; 
        } 
          
        return res; 
    } 
      
    // Returns n^(-1) mod p 
    static long modInverse(long n) 
    {   return power(n, prime-2);   } 
      
    // Returns nCr % p using Fermat's little theorem. 
    static long nCrModPFermat(int n, int r) 
    { 
        // Base case 
        if (r == 0) 
            return 1; 
        long a1 = fact[n];
        long a2 = modInverse(fact[r]) % prime;
        long a3 = modInverse(fact[n-r]) % prime;
        return ((fact[n] * a2)%prime * a3) % prime; 
    } 
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        {  br = new BufferedReader(new InputStreamReader(System.in));  } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) { 
                try{    st = new StringTokenizer(br.readLine()); 
                }catch (IOException  e) { 
                    //e.printStackTrace();
                }
            } 
            return st.nextToken(); 
        }
  
        int nextInt() 
        { return Integer.parseInt(next());  } 
  
        long nextLong() 
        {  return Long.parseLong(next());  } 
  
        double nextDouble() 
        {  return Double.parseDouble(next());  } 
        
        long[] nextLongArray(int n){
            long[] a = new long[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextLong();  }
            return a;
        }
        
        int[] nextIntArray(int n){
            int[] a = new int[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextInt();   }
            return a;
        }
        String nextLine() { 
            String str = ""; 
            try{    str = br.readLine(); 
            } catch (IOException e) { 
                //e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	
	
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main
{
 
 
	public static void main (String[] args) throws java.lang.Exception {
	    FastReader reader = new FastReader();
	    int temp = reader.nextInt() % 1000;
		if(temp  == 0){
                System.out.println(0);
        }else{
                          System.out.println(1000-temp);
        }

			    
    }
    
 
 
 /* Iterative Function to calculate  (x^y)%p in O(log y) */
 
    public static long prime = 1000000007;
    public static long[] fact;
    static long power(long x, long y) 
    { 
        // Initialize result 
        long res = 1; 
        // Update x if it is more than or 
        // equal to p 
        x = x % prime; 
                      
        while (y > 0) 
        { 
            // If y is odd, multiply x  with result 
            if (y % 2 == 1) 
                res = (res * x) % prime; 
            // y must be even now 
            y = y >> 1; // y = y/2 
            x = (x * x) % prime; 
        } 
          
        return res; 
    } 
      
    // Returns n^(-1) mod p 
    static long modInverse(long n) 
    {   return power(n, prime-2);   } 
      
    // Returns nCr % p using Fermat's little theorem. 
    static long nCrModPFermat(int n, int r) 
    { 
        // Base case 
        if (r == 0) 
            return 1; 
        long a1 = fact[n];
        long a2 = modInverse(fact[r]) % prime;
        long a3 = modInverse(fact[n-r]) % prime;
        return ((fact[n] * a2)%prime * a3) % prime; 
    } 
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        {  br = new BufferedReader(new InputStreamReader(System.in));  } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) { 
                try{    st = new StringTokenizer(br.readLine()); 
                }catch (IOException  e) { 
                    //e.printStackTrace();
                }
            } 
            return st.nextToken(); 
        }
  
        int nextInt() 
        { return Integer.parseInt(next());  } 
  
        long nextLong() 
        {  return Long.parseLong(next());  } 
  
        double nextDouble() 
        {  return Double.parseDouble(next());  } 
        
        long[] nextLongArray(int n){
            long[] a = new long[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextLong();  }
            return a;
        }
        
        int[] nextIntArray(int n){
            int[] a = new int[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextInt();   }
            return a;
        }
        String nextLine() { 
            String str = ""; 
            try{    str = br.readLine(); 
            } catch (IOException e) { 
                //e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	
	
} Main public static long prime = 1000000007; prime 1000000007 public static long[] fact; fact public static void main (String[] args) throws java.lang.Exception {
	    FastReader reader = new FastReader();
	    int temp = reader.nextInt() % 1000;
		if(temp  == 0){
                System.out.println(0);
        }else{
                          System.out.println(1000-temp);
        }

			    
    } main {
	    FastReader reader = new FastReader();
	    int temp = reader.nextInt() % 1000;
		if(temp  == 0){
                System.out.println(0);
        }else{
                          System.out.println(1000-temp);
        }

			    
    } FastReader reader = new FastReader(); reader new FastReader() int temp = reader.nextInt() % 1000; temp reader.nextInt() % 1000 reader.nextInt() reader.nextInt reader 1000 if(temp  == 0){
                System.out.println(0);
        }else{
                          System.out.println(1000-temp);
        } temp  == 0 temp 0 {
                System.out.println(0);
        } System.out.println(0) System.out.println System.out System System.out 0 {
                          System.out.println(1000-temp);
        } System.out.println(1000-temp) System.out.println System.out System System.out 1000-temp 1000 temp String[] args args static long power(long x, long y) 
    { 
        // Initialize result 
        long res = 1; 
        // Update x if it is more than or 
        // equal to p 
        x = x % prime; 
                      
        while (y > 0) 
        { 
            // If y is odd, multiply x  with result 
            if (y % 2 == 1) 
                res = (res * x) % prime; 
            // y must be even now 
            y = y >> 1; // y = y/2 
            x = (x * x) % prime; 
        } 
          
        return res; 
    } power { 
        // Initialize result 
        long res = 1; 
        // Update x if it is more than or 
        // equal to p 
        x = x % prime; 
                      
        while (y > 0) 
        { 
            // If y is odd, multiply x  with result 
            if (y % 2 == 1) 
                res = (res * x) % prime; 
            // y must be even now 
            y = y >> 1; // y = y/2 
            x = (x * x) % prime; 
        } 
          
        return res; 
    } long res = 1; res 1 x = x % prime x x % prime x prime while (y > 0) 
        { 
            // If y is odd, multiply x  with result 
            if (y % 2 == 1) 
                res = (res * x) % prime; 
            // y must be even now 
            y = y >> 1; // y = y/2 
            x = (x * x) % prime; 
        } y > 0 y 0 { 
            // If y is odd, multiply x  with result 
            if (y % 2 == 1) 
                res = (res * x) % prime; 
            // y must be even now 
            y = y >> 1; // y = y/2 
            x = (x * x) % prime; 
        } if (y % 2 == 1) 
                res = (res * x) % prime; y % 2 == 1 y % 2 y 2 1 res = (res * x) % prime res (res * x) % prime (res * x) res x prime y = y >> 1 y y >> 1 y 1 x = (x * x) % prime x (x * x) % prime (x * x) x x prime return res; res long x x long y y // Returns n^(-1) mod p 
    static long modInverse(long n) 
    {   return power(n, prime-2);   } modInverse {   return power(n, prime-2);   } return power(n, prime-2); power(n, prime-2) power n prime-2 prime 2 long n n // Returns nCr % p using Fermat's little theorem. 
    static long nCrModPFermat(int n, int r) 
    { 
        // Base case 
        if (r == 0) 
            return 1; 
        long a1 = fact[n];
        long a2 = modInverse(fact[r]) % prime;
        long a3 = modInverse(fact[n-r]) % prime;
        return ((fact[n] * a2)%prime * a3) % prime; 
    } nCrModPFermat { 
        // Base case 
        if (r == 0) 
            return 1; 
        long a1 = fact[n];
        long a2 = modInverse(fact[r]) % prime;
        long a3 = modInverse(fact[n-r]) % prime;
        return ((fact[n] * a2)%prime * a3) % prime; 
    } if (r == 0) 
            return 1; r == 0 r 0 return 1; 1 long a1 = fact[n]; a1 fact[n] fact n long a2 = modInverse(fact[r]) % prime; a2 modInverse(fact[r]) % prime modInverse(fact[r]) modInverse fact[r] fact r prime long a3 = modInverse(fact[n-r]) % prime; a3 modInverse(fact[n-r]) % prime modInverse(fact[n-r]) modInverse fact[n-r] fact n-r n r prime return ((fact[n] * a2)%prime * a3) % prime; ((fact[n] * a2)%prime * a3) % prime ((fact[n] * a2)%prime * a3) (fact[n] * a2)%prime (fact[n] * a2) fact[n] fact n a2 prime a3 prime int n n int r r static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        {  br = new BufferedReader(new InputStreamReader(System.in));  } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) { 
                try{    st = new StringTokenizer(br.readLine()); 
                }catch (IOException  e) { 
                    //e.printStackTrace();
                }
            } 
            return st.nextToken(); 
        }
  
        int nextInt() 
        { return Integer.parseInt(next());  } 
  
        long nextLong() 
        {  return Long.parseLong(next());  } 
  
        double nextDouble() 
        {  return Double.parseDouble(next());  } 
        
        long[] nextLongArray(int n){
            long[] a = new long[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextLong();  }
            return a;
        }
        
        int[] nextIntArray(int n){
            int[] a = new int[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextInt();   }
            return a;
        }
        String nextLine() { 
            String str = ""; 
            try{    str = br.readLine(); 
            } catch (IOException e) { 
                //e.printStackTrace(); 
            } 
            return str; 
        } 
    } FastReader BufferedReader br; br StringTokenizer st; st public FastReader() 
        {  br = new BufferedReader(new InputStreamReader(System.in));  } FastReader {  br = new BufferedReader(new InputStreamReader(System.in));  } br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String next() 
        { 
            while (st == null || !st.hasMoreElements()) { 
                try{    st = new StringTokenizer(br.readLine()); 
                }catch (IOException  e) { 
                    //e.printStackTrace();
                }
            } 
            return st.nextToken(); 
        } next { 
            while (st == null || !st.hasMoreElements()) { 
                try{    st = new StringTokenizer(br.readLine()); 
                }catch (IOException  e) { 
                    //e.printStackTrace();
                }
            } 
            return st.nextToken(); 
        } while (st == null || !st.hasMoreElements()) { 
                try{    st = new StringTokenizer(br.readLine()); 
                }catch (IOException  e) { 
                    //e.printStackTrace();
                }
            } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st { 
                try{    st = new StringTokenizer(br.readLine()); 
                }catch (IOException  e) { 
                    //e.printStackTrace();
                }
            } try{    st = new StringTokenizer(br.readLine()); 
                }catch (IOException  e) { 
                    //e.printStackTrace();
                } catch (IOException  e) { 
                    //e.printStackTrace();
                } IOException  e { 
                    //e.printStackTrace();
                } {    st = new StringTokenizer(br.readLine()); 
                } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt() 
        { return Integer.parseInt(next());  } nextInt { return Integer.parseInt(next());  } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() 
        {  return Long.parseLong(next());  } nextLong {  return Long.parseLong(next());  } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble() 
        {  return Double.parseDouble(next());  } nextDouble {  return Double.parseDouble(next());  } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next long[] nextLongArray(int n){
            long[] a = new long[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextLong();  }
            return a;
        } nextLongArray {
            long[] a = new long[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextLong();  }
            return a;
        } long[] a = new long[n]; a new long[n] n for(int i=0; i<n; i++)
            {   a[i] = nextLong();  } int i=0; int i=0; i 0 i<n i n i++ i++ i {   a[i] = nextLong();  } {   a[i] = nextLong();  } a[i] = nextLong() a[i] a i nextLong() nextLong return a; a int n n int[] nextIntArray(int n){
            int[] a = new int[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextInt();   }
            return a;
        } nextIntArray {
            int[] a = new int[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextInt();   }
            return a;
        } int[] a = new int[n]; a new int[n] n for(int i=0; i<n; i++)
            {   a[i] = nextInt();   } int i=0; int i=0; i 0 i<n i n i++ i++ i {   a[i] = nextInt();   } {   a[i] = nextInt();   } a[i] = nextInt() a[i] a i nextInt() nextInt return a; a int n n String nextLine() { 
            String str = ""; 
            try{    str = br.readLine(); 
            } catch (IOException e) { 
                //e.printStackTrace(); 
            } 
            return str; 
        } nextLine { 
            String str = ""; 
            try{    str = br.readLine(); 
            } catch (IOException e) { 
                //e.printStackTrace(); 
            } 
            return str; 
        } String str = ""; str "" try{    str = br.readLine(); 
            } catch (IOException e) { 
                //e.printStackTrace(); 
            } catch (IOException e) { 
                //e.printStackTrace(); 
            } IOException e { 
                //e.printStackTrace(); 
            } {    str = br.readLine(); 
            } str = br.readLine() str br.readLine() br.readLine br return str; str public class Main
{
 
 
	public static void main (String[] args) throws java.lang.Exception {
	    FastReader reader = new FastReader();
	    int temp = reader.nextInt() % 1000;
		if(temp  == 0){
                System.out.println(0);
        }else{
                          System.out.println(1000-temp);
        }

			    
    }
    
 
 
 /* Iterative Function to calculate  (x^y)%p in O(log y) */
 
    public static long prime = 1000000007;
    public static long[] fact;
    static long power(long x, long y) 
    { 
        // Initialize result 
        long res = 1; 
        // Update x if it is more than or 
        // equal to p 
        x = x % prime; 
                      
        while (y > 0) 
        { 
            // If y is odd, multiply x  with result 
            if (y % 2 == 1) 
                res = (res * x) % prime; 
            // y must be even now 
            y = y >> 1; // y = y/2 
            x = (x * x) % prime; 
        } 
          
        return res; 
    } 
      
    // Returns n^(-1) mod p 
    static long modInverse(long n) 
    {   return power(n, prime-2);   } 
      
    // Returns nCr % p using Fermat's little theorem. 
    static long nCrModPFermat(int n, int r) 
    { 
        // Base case 
        if (r == 0) 
            return 1; 
        long a1 = fact[n];
        long a2 = modInverse(fact[r]) % prime;
        long a3 = modInverse(fact[n-r]) % prime;
        return ((fact[n] * a2)%prime * a3) % prime; 
    } 
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        {  br = new BufferedReader(new InputStreamReader(System.in));  } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) { 
                try{    st = new StringTokenizer(br.readLine()); 
                }catch (IOException  e) { 
                    //e.printStackTrace();
                }
            } 
            return st.nextToken(); 
        }
  
        int nextInt() 
        { return Integer.parseInt(next());  } 
  
        long nextLong() 
        {  return Long.parseLong(next());  } 
  
        double nextDouble() 
        {  return Double.parseDouble(next());  } 
        
        long[] nextLongArray(int n){
            long[] a = new long[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextLong();  }
            return a;
        }
        
        int[] nextIntArray(int n){
            int[] a = new int[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextInt();   }
            return a;
        }
        String nextLine() { 
            String str = ""; 
            try{    str = br.readLine(); 
            } catch (IOException e) { 
                //e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	
	
} public class Main
{
 
 
	public static void main (String[] args) throws java.lang.Exception {
	    FastReader reader = new FastReader();
	    int temp = reader.nextInt() % 1000;
		if(temp  == 0){
                System.out.println(0);
        }else{
                          System.out.println(1000-temp);
        }

			    
    }
    
 
 
 /* Iterative Function to calculate  (x^y)%p in O(log y) */
 
    public static long prime = 1000000007;
    public static long[] fact;
    static long power(long x, long y) 
    { 
        // Initialize result 
        long res = 1; 
        // Update x if it is more than or 
        // equal to p 
        x = x % prime; 
                      
        while (y > 0) 
        { 
            // If y is odd, multiply x  with result 
            if (y % 2 == 1) 
                res = (res * x) % prime; 
            // y must be even now 
            y = y >> 1; // y = y/2 
            x = (x * x) % prime; 
        } 
          
        return res; 
    } 
      
    // Returns n^(-1) mod p 
    static long modInverse(long n) 
    {   return power(n, prime-2);   } 
      
    // Returns nCr % p using Fermat's little theorem. 
    static long nCrModPFermat(int n, int r) 
    { 
        // Base case 
        if (r == 0) 
            return 1; 
        long a1 = fact[n];
        long a2 = modInverse(fact[r]) % prime;
        long a3 = modInverse(fact[n-r]) % prime;
        return ((fact[n] * a2)%prime * a3) % prime; 
    } 
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        {  br = new BufferedReader(new InputStreamReader(System.in));  } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) { 
                try{    st = new StringTokenizer(br.readLine()); 
                }catch (IOException  e) { 
                    //e.printStackTrace();
                }
            } 
            return st.nextToken(); 
        }
  
        int nextInt() 
        { return Integer.parseInt(next());  } 
  
        long nextLong() 
        {  return Long.parseLong(next());  } 
  
        double nextDouble() 
        {  return Double.parseDouble(next());  } 
        
        long[] nextLongArray(int n){
            long[] a = new long[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextLong();  }
            return a;
        }
        
        int[] nextIntArray(int n){
            int[] a = new int[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextInt();   }
            return a;
        }
        String nextLine() { 
            String str = ""; 
            try{    str = br.readLine(); 
            } catch (IOException e) { 
                //e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	
	
} Main
//SHIVAM GARG
import java.util.*;
import java.lang.*;
import java.io.*;
 
/*
2
2
5 9
7
1 2 4 8 16 64 128
*/
public class Main
{
 
 
	public static void main (String[] args) throws java.lang.Exception {
	    FastReader reader = new FastReader();
	    int temp = reader.nextInt() % 1000;
		if(temp  == 0){
                System.out.println(0);
        }else{
                          System.out.println(1000-temp);
        }

			    
    }
    
 
 
 /* Iterative Function to calculate  (x^y)%p in O(log y) */
 
    public static long prime = 1000000007;
    public static long[] fact;
    static long power(long x, long y) 
    { 
        // Initialize result 
        long res = 1; 
        // Update x if it is more than or 
        // equal to p 
        x = x % prime; 
                      
        while (y > 0) 
        { 
            // If y is odd, multiply x  with result 
            if (y % 2 == 1) 
                res = (res * x) % prime; 
            // y must be even now 
            y = y >> 1; // y = y/2 
            x = (x * x) % prime; 
        } 
          
        return res; 
    } 
      
    // Returns n^(-1) mod p 
    static long modInverse(long n) 
    {   return power(n, prime-2);   } 
      
    // Returns nCr % p using Fermat's little theorem. 
    static long nCrModPFermat(int n, int r) 
    { 
        // Base case 
        if (r == 0) 
            return 1; 
        long a1 = fact[n];
        long a2 = modInverse(fact[r]) % prime;
        long a3 = modInverse(fact[n-r]) % prime;
        return ((fact[n] * a2)%prime * a3) % prime; 
    } 
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        {  br = new BufferedReader(new InputStreamReader(System.in));  } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) { 
                try{    st = new StringTokenizer(br.readLine()); 
                }catch (IOException  e) { 
                    //e.printStackTrace();
                }
            } 
            return st.nextToken(); 
        }
  
        int nextInt() 
        { return Integer.parseInt(next());  } 
  
        long nextLong() 
        {  return Long.parseLong(next());  } 
  
        double nextDouble() 
        {  return Double.parseDouble(next());  } 
        
        long[] nextLongArray(int n){
            long[] a = new long[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextLong();  }
            return a;
        }
        
        int[] nextIntArray(int n){
            int[] a = new int[n];
            for(int i=0; i<n; i++)
            {   a[i] = nextInt();   }
            return a;
        }
        String nextLine() { 
            String str = ""; 
            try{    str = br.readLine(); 
            } catch (IOException e) { 
                //e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	
	
}
