import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner koko = new Scanner(System.in); long n = koko.nextLong(); int m = koko.nextInt(); long modn = n%1000; long total = (n-modn)/1000; long modt = total%m; long h = (total-modt)/m; System.out.println(h*1000); } }