Problem F: String Problem F

Problem F: String Problem F

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 2713  Solved: 568
[Submit][Status][Web Board]

Description

There is a string \(S_0\) with length \(2m\). Its first half \(S_0[1,m]\) is the substitution cipher of the second half \(S_0[m+1,2m]\). Then for some reason, the second half of \(S_0\) may lose some characters at the end, resulting in string \(S\).

Given this string \(S\), you need to answer the smallest possible value of \(m\).

Hint: substitution cipher is an encryption method that replaces letters in the text with other letters. For example, if our encryption rule is \(a\to c,b\to a,c\to b\), then the string "accb" will be encrypted into "cbba".

Input

The first line is the code table for the substitution cipher, which contains 26 letters representing the encrypted letter for each letter in lexicographical order. 

The second line is \(S \ \ (1\leq |S| \leq 5\times 10^5)\).

Output

One integer, indicating the minimal possible length of the second half.

Sample Input

b c d e f g h i j k l m n o p q r s t u v w x y z a
bcdeabc

Sample Output

4

HINT

[Submit][Status]