class RH():

    def __init__(self, s, base, mod):

        self.base = base

        self.mod = mod

        self.rev = pow(base, mod-2, mod)



        l = len(s)

        self.h = h = [0]*(l+1)

        tmp = 0

        for i in range(l):

            num = ord(s[i])

            tmp = (tmp*base + num) % mod

            h[i+1] = tmp

    def calc(self, l, r):

        return (self.h[r] - self.h[l] * pow(self.base, r-l, self.mod)) % self.mod

    def fixed(self, length):

        v = pow(self.base, length, self.mod)

        h = self.h; mod = self.mod

        def fixed_calc(l):

            return (h[length+l] - h[l] * v) % mod

        return fixed_calc

T = eval(input()); P = eval(input())

MOD = 10**18+9

HT = RH(T, 11, MOD)

HP = RH(P, 11, MOD)



pv = HP.calc(0, len(P))

calc = HT.fixed(len(P))

for i in range(len(T)-len(P)+1):

    if calc(i) == pv:

        print(i)
import sys

readline = sys.stdin.readline

write = sys.stdout.write



class KMP:

    def __init__(self, W):

        L = len(W)

        T = [0] * (L+1)

        T[0] = -1

        c = 0

        for p in range(1, L):

            if W[p] == W[c]:

                T[p] = T[c]

            else:

                T[p] = c

                c = T[c]

                while c >= 0 and W[p] != W[c]:

                    c = T[c]

            c += 1

        T[L] = c

        self.T = T

        self.W = W



    def search(self, S):

        W = self.W; T = self.T

        R = []

        LS = len(S); LW = len(W)

        # S[i], W[j]

        i = j = 0

        while i < LS:

            if S[i] == W[j]:

                i += 1; j += 1

                if j == LW:

                    R.append(i-j)

                    j = T[j]

            else:

                j = T[j]

                if j < 0:

                    i += 1

                    j += 1

        return R



def solve():

    T = readline().strip()

    P = readline().strip()

    kmp = KMP(P)

    res = kmp.search(T)

    for p in res:

        write("%d\n" % p)

solve()

class RH:
    def __init__(self, s, base, mod):
        self.base = base
        self.mod = mod
        self.rev = pow(base, mod - 2, mod)
        l = len(s)
        self.h = h = [0] * (l + 1)
        tmp = 0
        for i in range(l):
            num = ord(s[i])
            tmp = (tmp * base + num) % mod
            h[i + 1] = tmp

    def calc(self, l, r):
        return (self.h[r] - self.h[l] * pow(self.base, r - l, self.mod)) % self.mod

    def fixed(self, length):
        v = pow(self.base, length, self.mod)
        h = self.h
        mod = self.mod

        def fixed_calc(l):
            return (h[length + l] - h[l] * v) % mod

        return fixed_calc


T = eval(input())
P = eval(input())
MOD = 10**18 + 9
HT = RH(T, 11, MOD)
HP = RH(P, 11, MOD)
pv = HP.calc(0, len(P))
calc = HT.fixed(len(P))
for i in range(len(T) - len(P) + 1):
    if calc(i) == pv:
        print(i)

import sys

readline = sys.stdin.readline
write = sys.stdout.write


class KMP:
    def __init__(self, W):
        L = len(W)
        T = [0] * (L + 1)
        T[0] = -1
        c = 0
        for p in range(1, L):
            if W[p] == W[c]:
                T[p] = T[c]
            else:
                T[p] = c
                c = T[c]
                while c >= 0 and W[p] != W[c]:
                    c = T[c]
            c += 1
        T[L] = c
        self.T = T
        self.W = W

    def search(self, S):
        W = self.W
        T = self.T
        R = []
        LS = len(S)
        LW = len(W)
        # S[i], W[j]
        i = j = 0
        while i < LS:
            if S[i] == W[j]:
                i += 1
                j += 1
                if j == LW:
                    R.append(i - j)
                    j = T[j]
            else:
                j = T[j]
                if j < 0:
                    i += 1
                    j += 1
        return R


def solve():
    T = readline().strip()
    P = readline().strip()
    kmp = KMP(P)
    res = kmp.search(T)
    for p in res:
        write("%d\n" % p)


solve()

-class RH: -    def __init__(self, s, base, mod): -        self.base = base -        self.mod = mod -        self.rev = pow(base, mod - 2, mod) -        l = len(s) -        self.h = h = [0] * (l + 1) -        tmp = 0 -        for i in range(l): -            num = ord(s[i]) -            tmp = (tmp * base + num) % mod -            h[i + 1] = tmp +import sys -    def calc(self, l, r): -        return (self.h[r] - self.h[l] * pow(self.base, r - l, self.mod)) % self.mod - -    def fixed(self, length): -        v = pow(self.base, length, self.mod) -        h = self.h -        mod = self.mod - -        def fixed_calc(l): -            return (h[length + l] - h[l] * v) % mod - -        return fixed_calc +readline = sys.stdin.readline +write = sys.stdout.write -T = eval(input()) -P = eval(input()) -MOD = 10**18 + 9 -HT = RH(T, 11, MOD) -HP = RH(P, 11, MOD) -pv = HP.calc(0, len(P)) -calc = HT.fixed(len(P)) -for i in range(len(T) - len(P) + 1): -    if calc(i) == pv: -        print(i) +class KMP: +    def __init__(self, W): +        L = len(W) +        T = [0] * (L + 1) +        T[0] = -1 +        c = 0 +        for p in range(1, L): +            if W[p] == W[c]: +                T[p] = T[c] +            else: +                T[p] = c +                c = T[c] +                while c >= 0 and W[p] != W[c]: +                    c = T[c] +            c += 1 +        T[L] = c +        self.T = T +        self.W = W + +    def search(self, S): +        W = self.W +        T = self.T +        R = [] +        LS = len(S) +        LW = len(W) +        # S[i], W[j] +        i = j = 0 +        while i < LS: +            if S[i] == W[j]: +                i += 1 +                j += 1 +                if j == LW: +                    R.append(i - j) +                    j = T[j] +            else: +                j = T[j] +                if j < 0: +                    i += 1 +                    j += 1 +        return R + + +def solve(): +    T = readline().strip() +    P = readline().strip() +    kmp = KMP(P) +    res = kmp.search(T) +    for p in res: +        write("%d\n" % p) + + +solve()