import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int num = scanner.nextInt();
    int answer = 0;
    
    for (int i = 1; i < 11; i++) {
      int bill = 1000*i;
      if (num > bill) {
      	continue;  
      } else {
       	answer = bill-num;
        break;
      }
    }
    System.out.println(answer);
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int num = scanner.nextInt();
    int answer = 0;
    
    for (int i = 1; i < 11; i++) {
      int bill = 1000*i;
      if (num > bill) {
      	continue;  
      } else {
       	answer = bill-num;
        break;
      }
    }
    System.out.println(answer);
  }
} Main public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int num = scanner.nextInt();
    int answer = 0;
    
    for (int i = 1; i < 11; i++) {
      int bill = 1000*i;
      if (num > bill) {
      	continue;  
      } else {
       	answer = bill-num;
        break;
      }
    }
    System.out.println(answer);
  } main {
    Scanner scanner = new Scanner(System.in);
    int num = scanner.nextInt();
    int answer = 0;
    
    for (int i = 1; i < 11; i++) {
      int bill = 1000*i;
      if (num > bill) {
      	continue;  
      } else {
       	answer = bill-num;
        break;
      }
    }
    System.out.println(answer);
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int num = scanner.nextInt(); num scanner.nextInt() scanner.nextInt scanner int answer = 0; answer 0 for (int i = 1; i < 11; i++) {
      int bill = 1000*i;
      if (num > bill) {
      	continue;  
      } else {
       	answer = bill-num;
        break;
      }
    } int i = 1; int i = 1; i 1 i < 11 i 11 i++ i++ i {
      int bill = 1000*i;
      if (num > bill) {
      	continue;  
      } else {
       	answer = bill-num;
        break;
      }
    } {
      int bill = 1000*i;
      if (num > bill) {
      	continue;  
      } else {
       	answer = bill-num;
        break;
      }
    } int bill = 1000*i; bill 1000*i 1000 i if (num > bill) {
      	continue;  
      } else {
       	answer = bill-num;
        break;
      } num > bill num bill {
      	continue;  
      } continue; {
       	answer = bill-num;
        break;
      } answer = bill-num answer bill-num bill num break; System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int num = scanner.nextInt();
    int answer = 0;
    
    for (int i = 1; i < 11; i++) {
      int bill = 1000*i;
      if (num > bill) {
      	continue;  
      } else {
       	answer = bill-num;
        break;
      }
    }
    System.out.println(answer);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int num = scanner.nextInt();
    int answer = 0;
    
    for (int i = 1; i < 11; i++) {
      int bill = 1000*i;
      if (num > bill) {
      	continue;  
      } else {
       	answer = bill-num;
        break;
      }
    }
    System.out.println(answer);
  }
} Main
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int num = scanner.nextInt();
    int answer = 0;
    
    for (int i = 1; i < 11; i++) {
      int bill = 1000*i;
      if (num > bill) {
      	continue;  
      } else {
       	answer = bill-num;
        break;
      }
    }
    System.out.println(answer);
  }
}