#include <bits/stdc++.h>
template <typename T>
inline bool MIN(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool MAX(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
inline int plu(int a, int b) {
  return a + b >= 1000000007 ? a + b - 1000000007 : a + b;
}
inline int sub(int a, int b) { return a - b < 0 ? a - b + 1000000007 : a - b; }
inline int mul(int a, int b) { return (long long)a * b % 1000000007; }
inline int inc(int &a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
inline int dec(int &a, int b) {
  a -= b;
  if (a < 0) a += 1000000007;
}
using namespace std;
int n, A[200010], m;
char s1[200010], s2[200010];
int ok(int L) {
  int p = 1;
  for (int i = 1; i <= n; ++i)
    if (A[i] <= L) {
      if (s1[i] == s2[p]) ++p;
      if (p > m) return 1;
    }
  return 0;
}
int main() {
  scanf("%s%s", s1 + 1, s2 + 1);
  n = strlen(s1 + 1);
  m = strlen(s2 + 1);
  for (int i = 1, a; i <= n; ++i) scanf("%d", &a), A[a] = n - i + 1;
  int l = 1, r = n + 1;
  while (l < r) {
    int mid = l + r >> 1;
    if (ok(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%d\n", n - l);
  return 0;
}
