using System;
public class Program
{
public static int fun1(String a , String b){
return a.IndexOf(b); // already implemented method that can be used
}
public static int fun2(String a, String b){
int i=0,j=0;
int idx = -1;
while (i<a.Length && j < b.Length){
if (a[i] == b[j]){
if (j == 0 )
idx = i;
j++;
else
j=0;
i++;
if (j != b.Length)
idx = -1;
return idx;
public static void Main()
String a,b;
a = Console.ReadLine();
b = Console.ReadLine();
Console.WriteLine(fun2(a,b));