题目描述
Problem Description
A rabbit is trying to make a signboard for Xmas Contest 2018. The signboard is a grid of rectangular cells, and each cell can contain one character. Cells without characters are allowed.
The characters the rabbit can write are either uppercase English letters (A-Z) or decorative star marks (*).
When the eel reads the signboard, it extracts a string from the signboard as follows:
- It looks at each row from the top row to the bottom row.
- For each row, if no cell in that row contains a character, the row is ignored.
- If there are cells with characters in the row, the character in the leftmost cell with a character is read.
The rabbit wants the string obtained by removing the star marks (*) from the string read by the eel to exactly match the string $ S $.
Moreover, the rabbit also wants the string obtained by removing the star marks (*) from the string read by the eel when the signboard is rotated 90 degrees to exactly match the string $ T $.
The rabbit is happy if the number of cells that need to be written on to satisfy the above conditions is minimized.
Input Format
$ S $ $ T $
Output Format
Output the minimum number of cells that need to be written on to create a signboard that satisfies the conditions in the problem statement. If it is impossible to create such a signboard, output $ -1 $ instead.
Sample Input and Output
Sample Input #1
USAGI
UNAGI
Sample Output #1
6
Sample Input #2
WA
AC
Sample Output #2
4
Notes/Hints
Constraints
- $1 \le |S| \le 50$.
- $1 \le |T| \le 50$.
- $ S $ and $ T $ consist only of uppercase English letters.
Sample Explanation 1
For example, the following arrangement of characters is possible. 
Sample Explanation 2
For example, the following arrangement of characters is possible.
Note that there is no limitation on the size of the grid.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分