using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(writer);

            var t = Console.ReadLine();
            var p = Console.ReadLine();

            var tHash = new RollingHash(t);
            var pHash = new RollingHash(p);
            ulong ph1, ph2;
            pHash.Slice(0, pHash.Length, out ph1, out ph2);
            for (int begin = 0; begin <= tHash.Length - pHash.Length; begin++)
            {
                ulong th1, th2;
                tHash.Slice(begin, pHash.Length, out th1, out th2);

                if (ph1 == th1 && ph2 == th2)
                {
                    Console.WriteLine(begin);
                }
            }

            Console.Out.Flush();
        }


        /// <summary>
        /// 参考: https://qiita.com/keymoon/items/11fac5627672a6d6a9f6
        /// ジェネリクスに対応させるにはGetHashCode()を足していく？実装によっては重そうなのでとりあえずパス。
        /// </summary>
        class RollingHash
        {
            const ulong Mask30 = (1UL << 30) - 1;
            const ulong Mask31 = (1UL << 31) - 1;
            const ulong Mod = (1UL << 61) - 1;
            const ulong Positivizer = Mod * ((1UL << 3) - 1);   // 引き算する前に足すことでmodが負になることを防ぐやつ
            static readonly uint base1;
            static readonly uint base2;
            static readonly List<ulong> pow1;
            static readonly List<ulong> pow2;

            static RollingHash()
            {
                var random = new Random();
                base1 = (uint)random.Next(129, int.MaxValue >> 1);
                base2 = (uint)random.Next(int.MaxValue >> 1, int.MaxValue); // 32bit目は0にしておく
                pow1 = new List<ulong>() { 1 };
                pow2 = new List<ulong>() { 1 };
            }

            ulong[] hash1;
            ulong[] hash2;
            public string RowString { get; }
            public int Length => RowString.Length;

            public RollingHash(string s)
            {
                RowString = s;
                hash1 = new ulong[s.Length + 1];
                hash2 = new ulong[s.Length + 1];

                for (int i = pow1.Count; i < s.Length + 1; i++)
                {
                    pow1.Add(CalculateModular(Multiply(pow1[i - 1], base1)));
                    pow2.Add(CalculateModular(Multiply(pow2[i - 1], base2)));
                }

                for (int i = 0; i < s.Length; i++)
                {
                    hash1[i + 1] = CalculateModular(Multiply(hash1[i], base1) + s[i]);
                    hash2[i + 1] = CalculateModular(Multiply(hash2[i], base2) + s[i]);
                }
            }

            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public void Slice(int begin, int length, out ulong h1, out ulong h2)
            {
                h1 = CalculateModular(hash1[begin + length] + Positivizer - Multiply(hash1[begin], pow1[length]));
                h2 = CalculateModular(hash2[begin + length] + Positivizer - Multiply(hash2[begin], pow2[length]));
            }


            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            private static ulong Multiply(ulong l, ulong r)
            {
                var lu = l >> 31;
                var ll = l & Mask31;
                var ru = r >> 31;
                var rl = r & Mask31;
                var mid = ll * ru + lu * rl;
                return ((lu * ru) << 1) + ll * rl + ((mid & Mask30) << 31) + (mid >> 30);   // a * 2^61 ≡ a (mod 2^61 - 1)を使う
            }

            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            private static ulong Multiply(ulong l, uint r)
            {
                var lu = l >> 31;
                var mid = lu * r;
                return (l & Mask31) * r + ((mid & Mask30) << 31) + (mid >> 30); // rの32bit目は0としている
            }

            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            private static ulong CalculateModular(ulong value)
            {
                value = (value & Mod) + (value >> 61);
                if (value >= Mod)
                {
                    value -= Mod;
                }
                return value;
            }

            public override string ToString() => RowString;
        }
    }
}



Measured memory_bytes: 59892