main = do w<-fmap read getLine d<-fmap read getLine print$foldr (\v r->r-(div r $v*v)) w [2..d]