시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 3 3 3 100.000%

문제

Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.

Sergey gives Nastya the word $t$ and wants to get the word $p$ out of it. Nastya removes letters in a certain order, which is specified by permutation of letters' indices of the word $t$: $a_1 \ldots a_{|t|}$ . Note that after removing one letter, the indices of other letters don't change. Sergey knows this permutation. His goal is to stop his sister at some point and continue removing by himself to get the word $p$. Since Nastya likes this activity, Sergey wants to stop her as late as possible. Your task is to determine, how many letters Nastya can remove before she will be stopped by Sergey.

It is guaranteed that the word $p$ can be obtained by removing the letters from word $t$.

입력

The first and second lines of the input file contain the words $t$ and $p$, respectively. Words are composed of lowercase letters of the Latin alphabet ($1 \le |p| < |t| \le  200 \, 000$) .

Next line contains a permutation $a_1 \ldots a_{|t|}$ of letter indices that specifies the order in which Nastya removes letters of $t$ ($1 \le a_i \le |t|$, all $a_i$ are distinct).

출력

Print a single integer number, the maximum number of letters that Nastya can remove.

서브태스크

번호 배점 제한
1 32

$|t| \le 5000 $

2 36

$|t| \le 2 \cdot 10^5$, all letters in $p$ are equal

3 32

$|t| \le 2 \cdot 10^5$

예제 입력 1

ababcba
abb
5 3 4 1 7 6 2

예제 출력 1

3

힌트

Sequence of removing made by Nastya looks like this:

"ababcba" $\rightarrow$ "ababcba" $\rightarrow$ "ababcba" $\rightarrow$ "ababcba

Nastya can not continue, because it is impossible to get word "abb" from word "ababcba".

So, Nastya will remove only three letters.

채점 및 기타 정보

  • 예제는 채점하지 않는다.