package P128; import java.util.Scanner; public class P128 { public static void main(String args[]){ Scanner sc = new Scanner(System.in); String n = sc.nextLine(); double nd = Double.parseDouble(n); String m = sc.nextLine(); double md = Double.parseDouble(m); double sheet = Math.floor(nd/1000); double ans; ans = 1000*((sheet-(sheet%md))/md); System.out.printf("%.0f",ans); } }