using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Math;
using System.Text.RegularExpressions;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        public void Solve(ConsoleInput cin) {
            var T = cin.ReadLine;
            var P = cin.ReadLine;
            var L = KMPSearchAll(P, T).ToArray();
            if(L.Any())Console.WriteLine(L.Join("\n"));
        }

        //https://www.hgc.jp/~tshibuya/classes/seq2019_1basic.pdf
        List<int> KMPSearchAll(string pat,string tar) {
            var Res = new List<int>();
            int[] Common;
            MakeKMPCommon(out Common, pat);
            //Console.WriteLine(Common.Join());
            int i = 0, j=0; 
            int PL = pat.Length, TL = tar.Length;
            while(i < TL - PL) {
                while(j < PL && pat[j] == tar[i + j]) {
                    j++;
                }   //$j is the first index of $pat which not coincide
                //if $j==$PL, $pat all coincides with $tar[i..i+PL]
                if(j == PL) {
                    Res.Add(i);
                } else if(j == 0) {
                    i++;
                }
                if(j != 0) {
                    var k = Common[j];
                    i += k == 0 ? (pat[0] == tar[i + j] ? j : j+1) : j - k;
                    j = k;
                }
            }
            i = TL - PL;
            if(i >= 0) {
                while(j < PL && pat[j] == tar[i + j]) {
                    j++;
                }
                if(j == PL) {
                    Res.Add(i);
                }
            }
            return Res;
        }
        //https://snuke.hatenablog.com/entry/2014/12/03/214243
        void MakeZ(out int[] Z, string pat) {
            var PL = pat.Length;
            Z = new int[PL];
            Z[0] = PL;
            int i = 1, j = 0;
            while(i < PL) {
                while(i + j < PL && pat[j] == pat[i + j]) ++j;
                Z[i] = j;
                if(j == 0) { ++i; continue; }
                int k = 1;
                while(i + k < PL && k + Z[k] < j) {
                    Z[i + k] = Z[k]; ++k;
                }
                i += k; j -= k;
            }
        }
        //https://www.hgc.jp/~tshibuya/classes/seq2019_1basic.pdf
        void MakeKMPCommon(out int[] D, string pat) {
            int[] Z;
            MakeZ(out Z, pat);
            var PL = pat.Length;
            D = new int[PL + 1];
            for(int i = 1; i < PL; i++) {
                if(D[i + Z[i]] == 0) D[i + Z[i]] = Z[i];
            }
        }
    }

    static class ExtendClass {
        public static void Swap<T>(this T[] X, int i, int j) {
            T tmp = X[i];
            X[i] = X[j];
            X[j] = tmp;
        }
        public static string Join<T>(this T[] X, string separator = " ") => string.Join(separator, X);
        public static S[] Clone<S>(this S[] src) where S : struct {
            var res = new S[src.Length];
            Array.Copy(src, res, src.Length);
            return res;
        }
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}



Measured memory_bytes: 18604