#GYM104720E. Dish Ordering

Dish Ordering

本题没有可用的提交语言。

Description

Meri, the famous prodigy mouse chef, helping to prepare a huge order of $n$ dishes with the help of her sidekick, Albert Spaghetti.

The menu is rather small, and so each type of dish can be uniquely represented by a single uppercase letter, A-Z. As Meri and Albert put their finishing touches on the dishes, Meri realizes that the dishes are about to be served in the wrong order!

In particular, the current dishes are in the order $s_1, s_2, \ldots, s_n$, where $s_i$ signifies that the $i$th dish is of type $s_i$. However, the dishes need to be served in the order $t_1, t_2, \ldots, t_n$.

Meri is too small to move the dishes on her own, so she needs to tell Albert what to do! However, Meri's only form of communication involves tugging on his hair, which is only enough to get him to swap adjacent dishes.

Hurry! The customers are getting antsy, and the dishes need to be sent out as fast as possible. Can you get Meri and Albert to arrange the dishes in time (and keep their jobs?)

The first line of input contains a single integer, $n$ ($1 \leq n \leq 100$), representing the number of dishes.

The second line contains $n$ uppercase letters, $s_1, \ldots, s_n$, which is the current ordering of the dishes.

The third line contains $n$ uppercase letters, $t_1, \ldots, t_n$, which is the correct ordering of the dishes.

Output a single integer, the minimum number of swaps Albert needs to do to get the dishes in the right order. If it is not possible to rearrange the dishes, output -1.

Input

The first line of input contains a single integer, $n$ ($1 \leq n \leq 100$), representing the number of dishes.

The second line contains $n$ uppercase letters, $s_1, \ldots, s_n$, which is the current ordering of the dishes.

The third line contains $n$ uppercase letters, $t_1, \ldots, t_n$, which is the correct ordering of the dishes.

Output

Output a single integer, the minimum number of swaps Albert needs to do to get the dishes in the right order. If it is not possible to rearrange the dishes, output -1.

5
AAAAB
BAAAA
10
ABCDEFGHIJ
ABCDEFGHIK
10
CGCCIBUCZF
ICCBCUZCFG
4
-1
13

Note

In the first case, Meri swaps the B with the element on its right 4 times so that it reaches the front of the line.

In the second test case, there is no dish K, so Meri cannot achieve the correct dish ordering.