import java.util.Scanner; public class Main { long N; long M; long Dist; long Digit; boolean endflg; Scanner sc = new Scanner(System.in); public static void main(String[] args) { new Main().solve(); } void solve() { N = sc.nextLong(); M = sc.nextLong(); Dist = N / M; Dist = (Dist / 1000) * 1000; endflg = false; if(Dist < 1000) { System.out.println(0); } else { while(endflg) { if(Dist * M > N) { Dist = Dist - 1000; } else { endflg = true; } } System.out.println(Dist); } } }