#include<iostream>
using namespace std;
#include<string>
#include<stdio.h>

#define A 1995455101 // large prime number.
#define B 1995455447 // large prime number, bigger than A.

int main()
{
	char T[1000000]; scanf("%s", T); int len_T = 0; while(T[len_T]){ len_T++; };
	char P[10000];   scanf("%s", P); int len_P = 0; while(P[len_P]){ len_P++; };
    long long *has_T, *has_P;
    has_T = new long long [len_T];
    has_P = new long long [len_P];

    long long h = 0; int i;  // hash coding.
    // has_T[i] = (T[0]A^{i-1} + T[1]A^{i-2} + ... + T[i-1]A + T[i]) % B.
    for(i = 0; i < len_T; i++){ h = (h * A + T[i]) % B; has_T[i] = h; }
    h = 0;
    // has_P[i] = (P[0]A^{i-1} + P[1]A^{i-2} + ... + P[i-1]A + P[i]) % B.
    for(i = 0; i < len_P; i++){ h = (h * A + P[i]) % B; has_P[i] = h; }

    // last_has = (P[0]A^{len_P-1} + P[1]A^{len_P-2} + ... + P[len_P-1]) % B.
    long long last_has = has_P[len_P - 1];
    // A^{len_P} Mod B.
    long long power, x, y, z;
    x = A, y = len_P, z = 1;
    for( ; y; y /= 2){
        if((y & 1) != 0){ z = (z * x) % B; }
        x = (x * x) % B;
    }
    power = z;

    for(i = len_P - 1; i < len_T; i++){
        if(has_T[i] == ((i >= len_P ? has_T[i - len_P] : 0) * power + last_has) % B){
			printf("%d\n", i - len_P + 1);
        }
    }
    delete [] has_T; delete [] has_P;

    return 0;
}