import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.bitmanip;


void main() {
    auto S = readln.chomp;
    auto T = readln.chomp;
    auto N = S.length.to!int;
    auto M = T.length.to!int;
    auto A = readln.split.map!(to!int).array;
    auto B = new int[](N);
    foreach (i; 0..N) {
        B[A[i]-1] = i;
    }

    int hi = N;
    int lo = M - 1;
    while (hi - lo > 1) {
        int mid = (hi + lo) / 2;
        int cnt = 0;
        int del = N - mid;
        foreach (i; 0..N) {
            if (B[i] < del)
                continue;
            if (S[i] == T[cnt])
                cnt += 1;
            if (cnt >= M)
                break;
        }
        if (cnt >= M)
            hi = mid;
        else
            lo = mid;
    }

    (N-hi).writeln;
}
