This problem is different from World Fragments II and World Fragments III. Please read the statements carefully.
You are given two non-negative binary integers and
without leading zeros. You can apply the following operation to
any number of times (possibly zero):
Choose a digit in
.
Let either or
.
For example, when you can choose the digit
in
, then let
.
Find out the least number of operations needed to turn into
. Print
if it is impossible to turn
into
.
The first line contains a non-negative binary integer
. It is guaranteed that
has at most
digits.
The second line contains a non-negative binary integer
. It is guaranteed that
has at most
digits.
Print a decimal integer in a single line, denoting the answer. If it is impossible to turn
into
.
In the first sample, the optimal way to apply the operation is shown as following:
Choose the digit , then let
.