using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        long N = long.Parse(Console.ReadLine());
        long M = long.Parse(Console.ReadLine());

        long ans = (N / M) - (N / M) % 1000;

        Console.WriteLine(ans);
    }
}