#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

struct Int61 {
    static const ull MOD = (1ULL << 61) - 1;
    // x = x1*2^31 + x0, x1 < 2^30, x0 < 2^31
    static const ull MASK61 = MOD;
    static const ull MASK31 = (1ULL << 31) - 1;
    static const ull MASK30 = (1ULL << 30) - 1;
    static inline ull Mod(ull x) {
        ull r = (x & MASK61) + (x >> 61);
        if ( r >= MOD ) r -= MOD;
        return r;
    }
    static inline ull Add(ull x, ull y) { 
        return Mod(x+y);
    }
    static ull Mul(ull x, ull y) {
        if ( x >= MOD ) x = Mod(x);
        if ( y >= MOD ) y = Mod(y);
        ull x1 = x >> 31, x0 = x & MASK31;
        ull y1 = y >> 31, y0 = y & MASK31;
        ull m = x1 * y0 + x0 * y1;
        ll r = 0;
        r += x0 * y0;
        r += (m >> 30) + ((m & MASK30) << 31);
        r += x1 * y1 * 2;
        return Mod(r); 
    }
    static ull Pow(ull x, ull n) {
        ull t = Mod(x), r = 1;
        while ( n > 0 ) {
            if ( n & 1 ) r = Mul(r, t);
            t = Mul(t, t);
            n >>= 1;
        }
        return r;
    }
    static ull Inv(ull a) {
        return Pow(a, MOD - 2);
    }
};

struct RollingHash {
    ull shift;
    ull base;
    ull inv_base;
    ull hs;
    ull len;

    RollingHash(ull shift = 1, ull base = 1e9+9 ) : shift(shift), base(base), hs(0), len(0) {
        inv_base = Int61::Inv(base);
    }
    // (x + shift) must not be 0
    ull push_back(ull x) {
        hs = Int61::Mul(hs, base);
        hs = Int61::Add(hs, x + shift);
        len++;
        return hs;
    }
    ull pop_front(ull x) {
        if ( len <= 0 ) throw exception();
        ll f = Int61::Mul(x + shift, Int61::Pow(base, len-1));
        hs = Int61::Add(hs, Int61::MOD - f);
        len--;
        return hs;
    }
    void clear() {
        hs = 0;
        len = 0;
    }
};

template<typename T> struct RollingHashVector {
    // hv[i]:v[0,i]に対するhash
    RollingHash rh;
    vector<ull> hv;
    vector<ull> pow_b;
    RollingHashVector(vector<T>& v, bool pre_calc_base_pow = false, ull shift = 1, ull base = 1e9+9 ) {
        rh = RollingHash(shift, base);
        hv.resize(v.size());
        for ( int i = 0; i < v.size(); i++ ) {
            hv[i] = rh.push_back((ull)v[i]);
        }
        if ( pre_calc_base_pow ) {
            ull p = 1;
            for ( int i = 0; i <= v.size(); i++ ) {
                pow_b.push_back(p);
                p = Int61::Mul(p, rh.base);
            }
        }
    }
    // v[l,r) に対するhash, 0<=l<=r<=v.size()
    // 長さlenの区間v[l,l+len)に対してはquery(l,l+len)
    ull query(int l, int r) {
        if ( l > r ) throw exception();
        ull pw = pow_b.empty() ? Int61::Pow(rh.base, r-l) : pow_b[r-l];
        ull hl = Int61::Mul(l > 0 ? hv[l-1] : 0, pw);
        ull hr = r > 0 ? hv[r-1] : 0;
        ull h = Int61::Add(hr, Int61::MOD - hl);
        return h;
    }
};

//------------------------
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_B&lang=jp
void test() {
    string T, P;
    cin >> T >> P;
    vector<char> t(T.begin(), T.end()), p(P.begin(), P.end());
    RollingHashVector<char> rht(t,true), rhp(p);
    ull h = rhp.query(0,p.size());
    for ( int i = 0; i < T.size(); i++ ) {
        if ( rht.query(i, i+p.size()) == h ) {
            cout << i << "\n";
        }
    }
}

int main() {
    test();
    return 0;
}



Measured memory_bytes: 21512