let () = Scanf.scanf "%s\n%d\n" @@ fun s k ->
  Printf.printf "%c\n" @@
    try
      List.find (( <> ) '1') @@ Array.to_list @@
        Array.init (min k (String.length s)) @@ String.get s
    with Not_found -> '1'
