Escape Sequences

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

For a string ss consisting of only "a" and "b" , let f(s)f(s) be the string obtained by replacing all "a" in ss with "aa" and "b" with "ab". For example, f(f("aba")) = "aaabaa".

Given strings ss and tt, determine the smallest non-negative integer kk where tt is a consecutive substring of fk(s)f^k(s).

Note that fkf^k is defined by:

  • f0(s)=sf^0(s) = s;
  • fk(s)=fk1(f(s))f^k(s) = f^{k - 1}(f(s)).

입력

The first and second lines contain string ss and tt respectively (1s,t21051 \leq |s|, |t| \leq 2 \cdot 10^5).

Strings ss and tt consist of only characters "a" and "b".

출력

A single integer denotes the minimum kk.

If kk does not exists, print "-1" instead.