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