let () =
  let x = read_int () in
  let coins = (ref 0, ref 0) in
  if x / 500 <> 0 then fst coins := x / 500 ;
  if x mod 500 / 5 <> 0 then snd coins := x mod 500 / 5 ;
  print_int ((!(fst coins) * 1000) + (!(snd coins) * 5))
