Finn is playing a game of "Flip it and Stick it" which is abbreviated as FiSi. FiSi is a one-player game played on two strings, S and T, of 0s and 1s. Finn is allowed to make moves of the following form:
For example, Finn may take the string S= 101100, take the substring 011 starting at index 2 (assuming 1-based string indexing), and create the string S= 111000 in one move. Finn wins the game if S does not contain T as a substring. Your task is to help Finn determine the length of the shortest winning sequence of moves or tell him that the game cannot be won.
The first line of input contains the string S (1≤∣S∣≤200,000).
The second line of input contains the string T (1≤∣T∣≤3).
In the table below, T_1 is the first bit in T, T_2 is the second bit in T, and T_3 is the third bit in T, when reading from left-to-right.
Output the minimum number of moves needed or -1 if it is impossible to win the game.