#include<bits/stdc++.h>
#define N 1000050
using namespace std;
string s1,s2; int vis[N],ch[N][26],fail[N],tot;
void Insert(string s){
int len = s.length(),now=0;
for(int i=0;i<len;i++){
int pos = s[i]-'a';
if(!ch[now][pos]) ch[now][pos] = ++tot;
now = ch[now][pos];
}vis[now] = 1;
}
void build(){
queue<int> q;
for(int i=0;i<26;i++) if(ch[0][i]) q.push(ch[0][i]);
while(!q.empty()){
int x = q.front(); q.pop();
for(int i=0;i<26;i++){
int j = fail[x];
while(j && !ch[j][i]) j = fail[j];
if(ch[x][i]) fail[ch[x][i]] = ch[j][i] , q.push(ch[x][i]);
else ch[x][i] = ch[j][i];
}
}
}
int main(){
cin>>s1>>s2; Insert(s2); build();
int len = s1.length() , now=0 , flag=0 , len2=s2.length();
for(int i=0;i<len;i++){
now = ch[now][s1[i]-'a'];
if(vis[now]){printf("%d\n",i-len2+2); flag=1;}
// while(j){
// if(vis[j]){printf("%d\n",i-1); flag=1; break;}
// j = fail[j];
// }
} if(!flag) printf("NO"); return 0;
}