#include <bits/stdc++.h>
using namespace std;
template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    for (int i=0; i<(((int)(v).size())); ++i) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}
template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;
/*
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    return 0;
}
*/
/**
* @brief 文字列のハッシュ化
* @author habara-k
* @date 2020/04/26
*/
struct RollingHash {
    using uint = uint64_t;
    /**
    * @brief コンストラクタ. O(|s|)
    * @param[in] s ハッシュ化する文字列(or vector).
    * @param[in] base ハッシュ化に使う基数. RollingHash::gen_base で作る.
    * @details 使い方
    *   auto base = RollingHash::gen_base();
    *
    *   string t; cin >> t;
    *   RollingHash hash(t, base);
    */
    template<typename S>
    RollingHash(const S& s, uint base) {
        int n = s.size();
        hash.assign(n+1, 0);
        pow.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash[i+1] = mod(mul(hash[i], base) + s[i]);
            pow[i+1] = mul(pow[i], base);
        }
    }
    /**
    * @brief ハッシュを計算する. O(1)
    * @param[in] l, r ハッシュを計算したい区間.
    * @return 区間[l, r) のハッシュ.
    * @details 使い方
    *   cout << hash.get(0, t.size()) << endl;
    */
    uint get(int l, int r) const {
        return mod(hash[r] + MASK61 - mul(hash[l], pow[r - l]));
    }
    /**
    * @brief 基数を生成する. O(1)
    * @return ランダムな基数.
    * @details 使い方
    *   auto base = RollingHash::gen_base();
    */
    static uint gen_base() {
        mt19937 random{random_device{}()};
        uniform_int_distribution<uint> dist(2, MASK61-2);
        return dist(random);
    }
private:
    vector<uint> hash, pow;
    static const uint MASK30 = (1LL<<30)-1,
                      MASK31 = (1LL<<31)-1,
                      MASK61 = (1LL<<61)-1;
    static uint mul(uint a, uint b) {
        uint au = a >> 31, ad = a & MASK31,
             bu = b >> 31, bd = b & MASK31;
        uint m = au * bd + ad * bu;
        uint mu = m >> 30, md = m & MASK30;
        return mod(au*bu*2 + mu + (md<<31) + ad*bd);
    }
    static uint mod(uint x) {
        uint xu = x >> 61, xd = x & MASK61;
        uint ret = xu + xd;
        if (ret >= MASK61) ret -= MASK61;
        return ret;
    }
};
int main() {
    string T, P;
    cin >> T >> P;
    int n = T.size(), m = P.size();
    auto base = RollingHash::gen_base();
    RollingHash rht(T, base);
    RollingHash rhp(P, base);
    for (int i = 0; i+m <= n; ++i) {
        if (rht.get(i, i+m) == rhp.get(0, m)) {
            cout << i << endl;
        }
    }
}




Measured memory_bytes: 19816