#include <bits/stdc++.h>
using namespace std;
inline int Readin() {
  register int K = 0, F = 1;
  register char C = getchar();
  while (C < '0' or C > '9') F = C == '-' ? -1 : 1, C = getchar();
  while (C >= '0' and C <= '9')
    K = (K << 3) + (K << 1) + C - '0', C = getchar();
  return F * K;
}
const int MaxN = 200000 + 10;
int N, M;
char S[MaxN], T[MaxN];
int A[MaxN], Inva[MaxN];
inline bool Check(int Num) {
  int Match = 0;
  for (register int i = 1; i <= N and Match < M; ++i)
    if (T[Match + 1] == S[i] and Inva[i] >= Num) ++Match;
  return Match == M;
}
int main() {
  scanf("%s%s", S + 1, T + 1);
  N = strlen(S + 1);
  M = strlen(T + 1);
  for (register int i = 0; ++i <= N; A[i] = Readin(), Inva[A[i]] = i)
    ;
  int L = 1, R = N + 1;
  while (L < R) {
    register int Mid = L + R >> 1;
    Check(Mid) ? L = Mid + 1 : R = Mid;
  }
  return not printf("%d\n", L - 2);
}
