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.next()); long r = Long.parseLong(sc.next()); long c = Long.parseLong(sc.next()); final long y = 1000; long x = y / c; System.out.println((x >= l && x <= r) ? y - (c * x) : y - (c * r)); sc.close(); } }