let quick_search s p f =
  let sl = String.length s in
  let pl = String.length p in
  let tbl = Hashtbl.create pl in
  let set_tbl () =
    String.iteri (fun i c -> Hashtbl.replace tbl c (pl - i)) p in
  let jump c =
    try Hashtbl.find tbl c with _ -> pl + 1 in
  let rec loopi i =
    if i > sl - pl then ()
    else
      let rec loopj j =
        if j = pl then begin
            f i;
            loopi (i+1)
          end
        else
          if s.[i+j] = p.[j] then loopj (j+1)
          else
            let i' = i + pl in
            if i' >= sl then loopi i'
            else loopi (jump s.[i'] + i)
      in
      loopj 0
  in
  set_tbl ();
  loopi 0

let () =
  let t = read_line () in
  let p = read_line () in
  let f x = string_of_int x |> print_endline in
  quick_search t p f