
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.nextLine();
    sc.close();

    if(n.length() == 4) {
      int bill = Integer.parseInt(n.substring(1, 4));
      if(bill == 0) {
        System.out.println(0);
      }else {
        System.out.println(1000 - bill);
      }

    }else if(n.length() == 5) {
      System.out.println(0);
    }else {
      System.out.println(1000 - Integer.parseInt(n));
    }
  }

} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.nextLine();
    sc.close();

    if(n.length() == 4) {
      int bill = Integer.parseInt(n.substring(1, 4));
      if(bill == 0) {
        System.out.println(0);
      }else {
        System.out.println(1000 - bill);
      }

    }else if(n.length() == 5) {
      System.out.println(0);
    }else {
      System.out.println(1000 - Integer.parseInt(n));
    }
  }

} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.nextLine();
    sc.close();

    if(n.length() == 4) {
      int bill = Integer.parseInt(n.substring(1, 4));
      if(bill == 0) {
        System.out.println(0);
      }else {
        System.out.println(1000 - bill);
      }

    }else if(n.length() == 5) {
      System.out.println(0);
    }else {
      System.out.println(1000 - Integer.parseInt(n));
    }
  } main {
    Scanner sc = new Scanner(System.in);
    String n = sc.nextLine();
    sc.close();

    if(n.length() == 4) {
      int bill = Integer.parseInt(n.substring(1, 4));
      if(bill == 0) {
        System.out.println(0);
      }else {
        System.out.println(1000 - bill);
      }

    }else if(n.length() == 5) {
      System.out.println(0);
    }else {
      System.out.println(1000 - Integer.parseInt(n));
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String n = sc.nextLine(); n sc.nextLine() sc.nextLine sc sc.close() sc.close sc if(n.length() == 4) {
      int bill = Integer.parseInt(n.substring(1, 4));
      if(bill == 0) {
        System.out.println(0);
      }else {
        System.out.println(1000 - bill);
      }

    }else if(n.length() == 5) {
      System.out.println(0);
    }else {
      System.out.println(1000 - Integer.parseInt(n));
    } n.length() == 4 n.length() n.length n 4 {
      int bill = Integer.parseInt(n.substring(1, 4));
      if(bill == 0) {
        System.out.println(0);
      }else {
        System.out.println(1000 - bill);
      }

    } int bill = Integer.parseInt(n.substring(1, 4)); bill Integer.parseInt(n.substring(1, 4)) Integer.parseInt Integer n.substring(1, 4) n.substring n 1 4 if(bill == 0) {
        System.out.println(0);
      }else {
        System.out.println(1000 - bill);
      } bill == 0 bill 0 {
        System.out.println(0);
      } System.out.println(0) System.out.println System.out System System.out 0 {
        System.out.println(1000 - bill);
      } System.out.println(1000 - bill) System.out.println System.out System System.out 1000 - bill 1000 bill if(n.length() == 5) {
      System.out.println(0);
    }else {
      System.out.println(1000 - Integer.parseInt(n));
    } n.length() == 5 n.length() n.length n 5 {
      System.out.println(0);
    } System.out.println(0) System.out.println System.out System System.out 0 {
      System.out.println(1000 - Integer.parseInt(n));
    } System.out.println(1000 - Integer.parseInt(n)) System.out.println System.out System System.out 1000 - Integer.parseInt(n) 1000 Integer.parseInt(n) Integer.parseInt Integer n String[] args args public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.nextLine();
    sc.close();

    if(n.length() == 4) {
      int bill = Integer.parseInt(n.substring(1, 4));
      if(bill == 0) {
        System.out.println(0);
      }else {
        System.out.println(1000 - bill);
      }

    }else if(n.length() == 5) {
      System.out.println(0);
    }else {
      System.out.println(1000 - Integer.parseInt(n));
    }
  }

} public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.nextLine();
    sc.close();

    if(n.length() == 4) {
      int bill = Integer.parseInt(n.substring(1, 4));
      if(bill == 0) {
        System.out.println(0);
      }else {
        System.out.println(1000 - bill);
      }

    }else if(n.length() == 5) {
      System.out.println(0);
    }else {
      System.out.println(1000 - Integer.parseInt(n));
    }
  }

} Main

import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.nextLine();
    sc.close();

    if(n.length() == 4) {
      int bill = Integer.parseInt(n.substring(1, 4));
      if(bill == 0) {
        System.out.println(0);
      }else {
        System.out.println(1000 - bill);
      }

    }else if(n.length() == 5) {
      System.out.println(0);
    }else {
      System.out.println(1000 - Integer.parseInt(n));
    }
  }

}
