let arr_of_str s = Array.init (String.length s) (fun i -> s.[i])
let () =
  Scanf.scanf "%s %d" @@ fun s k ->
  let s = arr_of_str s in
  if k = 1 then Printf.printf "%c\n" s.(0)
  else
    Array.fold_left (fun z c ->
      if z <> '1' then z else if c <> '1' then c else '1') '1' s
    |> Printf.printf "%c\n"