open Num

let prk ss ps f =
  let ssl = String.length ss in
  let psl = String.length ps in
  let m = (num_of_int 2) **/ (num_of_int 64) in
  let b = num_of_int 1000000007 in
  let rec pow a n =
    if n = 0 then a
    else  pow (mod_num (a */ b) m) (n-1) in
  let bb = pow (num_of_int 1) psl in
  let rh s =
    let h = ref (num_of_int 0) in
    String.iter (fun c -> h := mod_num (!h */ b +/ (num_of_int (Char.code c))) m) s; !h
  in
  let ih = rh (String.sub ss 0 psl) in
  let psh = rh ps in
  let rec loop h x =
    if h =/ psh then f x;
    if x = ssl - psl then ()
    else
      let nh = mod_num (h */ b +/ (num_of_int (Char.code ss.[x+psl])) -/ (num_of_int (Char.code ss.[x]) */ bb)) m in
      loop nh (x+1)
  in
  loop ih 0
      
let () =
  let t = read_line () in
  let p = read_line () in
  let f x = string_of_int x |> print_endline in
  prk t p f