#include <bits/stdc++.h>
char c1[300000], c2[300000];
int g[300000];
int i, l1, l2, t, l, r, mid;
inline bool check(int x) {
  for (int i = 1, k = 1; i <= l1; i++)
    if (g[i] > x) {
      if (c1[i] == c2[k]) k++;
      if (k > l2) return true;
    }
  return false;
}
int main() {
  gets(c1 + 1);
  gets(c2 + 1);
  l1 = strlen(c1 + 1);
  l2 = strlen(c2 + 1);
  for (i = 1; i <= l1; i++) scanf("%d", &t), g[t] = i;
  l = 0, r = l1;
  while (l < r) {
    mid = (l + r) / 2 + 1;
    if (check(mid))
      l = mid;
    else
      r = mid - 1;
  }
  printf("%d", l);
  return 0;
}
