#include <bits/stdc++.h>
using namespace std;
int n, m, x, del[300000];
char orig[300000], tar[300000];
bool check(int index) {
  int head = 0;
  for (int i = 0; i <= n - 1; i++) {
    if (del[i] <= index) {
    } else if (orig[i] == tar[head]) {
      head++;
    }
    if (head == m) return true;
  }
  return false;
}
int main() {
  gets(orig);
  gets(tar);
  n = strlen(orig), m = strlen(tar);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    del[x - 1] = i;
  }
  int l = 1, r = n, m = (l + r) / 2;
  while (l <= r) {
    bool exist = check(m);
    if (!exist)
      r = m - 1;
    else
      l = m + 1;
    m = (l + r) / 2;
  }
  printf("%d\n", l - 1);
  return 0;
}
