#coding:utf-8 N=input() M=input() if 1000 <= N//M: print N//M//1000*1000 else: print 0