#include <bits/stdc++.h>

using namespace std;

struct RollingHash
{
  typedef long long int_type;
  typedef pair<int_type, int_type> hash_type;

  int_type base, mod[2];

  vector<int_type> hashed[2], power[2];

  RollingHash(){ base = 9973LL, mod[0] = 999999937LL, mod[1] = 1000000007LL; }

  void init(const string& s)
  {
    int sz = s.size();
    
    for(int i = 0; i < 2; i++){
      hashed[i].assign(sz + 1, 0); 
      power[i].assign(sz + 1, 0);
      
      hashed[i][0] = 0;
      power[i][0] = 1;
      for(int j = 0; j < sz; j++){
	power[i][j+1] = power[i][j] * base % mod[i];
	hashed[i][j+1] = (hashed[i][j]+s[j])*base % mod[i];
      }
    }
  }

  hash_type get(int l, int r)
  {
    int_type hash1 = ((hashed[0][r] - hashed[0][l]*power[0][r-l]) % mod[0] + mod[0]) % mod[0];
    int_type hash2 = ((hashed[1][r] - hashed[1][l]*power[1][r-l]) % mod[1] + mod[1]) % mod[1];
    return hash_type(hash1, hash2);
  }
  
  hash_type concat(hash_type hash1, hash_type hash2, int hash2_len)
  {
    return hash_type((hash1.first*power[0][hash2_len] + hash2.first) % mod[0], 
		     (hash1.second*power[1][hash2_len] + hash2.second) % mod[1]);
  }
};

int main()
{
  string T, P;
  cin >> T >> P;

  RollingHash rollhash[2];
  rollhash[0].init(T);
  rollhash[1].init(P);

  for(int i = 0; i <= (int)(T.size()-P.size()); i++){
    if(rollhash[0].get(i, i+P.size()) == rollhash[1].get(0, P.size())) cout << i << endl;
  }

  return 0;
}