#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

ll mods[5] = {1000000007LL, 1000000009LL, 1000000021LL, 1000000033LL, 1000000087LL};
ll bs[5] = {10007, 10009, 10037, 10039, 10061};
ll psh, tsh, binv, bpow;
bool tok[1001000] = {false};

ll modpows(ll x, ll a, int mt){
  if(mods[mt] == 1)return 0;
  if(a == 0)return 1 % mods[mt];
  else if(a == 1)return x % mods[mt];
  else {
    ll res = modpows(x, a / 2, mt);
    res = res * res % mods[mt];
    if(a % 2 == 0)return res;
    else return res * x % mods[mt];
  }
}

signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase < 12;testcase++){
    string t, p; cin >> t >> p;
    if(t.size() < p.size())break;

    rep(i, t.size() - p.size() + 1)tok[i] = true;

    for(int mt = 0;mt < 3;++mt)for(int bt = 0;bt < 3;++bt){
      psh = 0; tsh = 0;
      rep(i, p.size()){
        psh = (psh * bs[bt] + (ll)(p[p.size() - 1 - i])) % mods[mt];
        tsh = (tsh * bs[bt] + (ll)(t[p.size() - 1 - i])) % mods[mt];
      }

      if(tsh != psh)tok[0] = false;
      binv = modpows(bs[bt], mods[mt] - 2, mt);
      bpow = modpows(bs[bt], p.size() - 1, mt);

      rep1(i, t.size() - p.size() + 1){
        tsh = ((tsh - (ll)t[i - 1]) * binv + (ll)t[i + p.size() - 1] * bpow) % mods[mt];
        if(tsh != psh)tok[i] = false;
      }
    }
    rep(i, t.size() - p.size() + 1)if(tok[i])pri(i);

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3104