use std::io::stdin;

/// エントリポイント
fn main() {
    let input = read_lines();
    println!("{}", lottery(input.0, input.1));
}

/// 標準入力から文字列を取得します。
fn read_lines() -> (String, String) {
    let mut str1 = String::new();
    stdin().read_line(&mut str1).unwrap();

    let mut str2 = String::new();
    stdin().read_line(&mut str2).unwrap();
    (str1, str2)
}

/// お年玉を均等に渡せる金額を返します。
fn lottery(budget: String, people: String) -> i64 {
    let budget = budget.parse::<i64>().unwrap();
    let people = people.parse::<i64>().unwrap();
    budget / 1000 / people * 1000
}