i=input s,t=i(),i() print(-1 if s==t else s.replace(t,t[0]+'.'+t[1:]).count('.'))