//Java kmp算法
import java.util.*;
public class Main
{
public static int kmp(String str,String sub)
{
int j = 0;
int n[] = next(sub);
for(int i = 0;i < str.length();i++)
{
while(j > 0 && str.charAt(i) != sub.charAt(j))
{
j = n[j - 1];
}
if(str.charAt(i) == sub.charAt(j))
{
j++;
}
if(sub.length() == j)
{
return i - j + 1;
}
}
return -1;
}
public static int[] next(String sub)
{
int next[] = new int[sub.length()];
int x = 0;
for(int i = 1;i < sub.length();i++)
{
while(x > 0 && sub.charAt(i) != sub.charAt(x))
{
x = next[x - 1];
}
if(sub.charAt(i) == sub.charAt(x))
{
x++;
}
next[i] = x;
}
return next;
}
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
String str = sc.next();
String sub = sc.next();
int index = kmp(str,sub);
System.out.println(index);
}
}