import java.util.Scanner; public class MyMain { final static String YUKICODER = "yukicoder"; public static void main(String[] args) { Scanner sc = new Scanner(System.in); long l = Long.parseLong(sc.nextLine()); long r = Long.parseLong(sc.nextLine()); long c = Long.parseLong(sc.nextLine()); final long y = 1000; long x = y / c; System.out.println((x >= l && x <= r) ? y - (c * x) : y - (c * r)); sc.close(); } }