#include <bits/stdc++.h>
using namespace std;
string a;
string b;
int c[200005];
int main() {
  int res = 0;
  cin >> a;
  cin >> b;
  int len = a.size();
  int blen = b.size();
  for (int i = 0; i < len; i++) {
    scanf("%d", &c[i]);
  }
  int le = 0, ri = len - 1;
  while (le <= ri) {
    int mid = (le + ri) / 2;
    string temp = a;
    for (int i = 0; i < mid; i++) {
      temp[c[i] - 1] = '.';
    }
    int bidx = 0;
    bool ok = false;
    for (int i = 0; i < len; i++) {
      if (temp[i] == b[bidx]) {
        bidx++;
      }
      if (bidx == blen) ok = true;
    }
    if (ok) {
      le = mid + 1;
      if (res < le) res = le;
    } else {
      ri = mid - 1;
    }
  }
  cout << res - 1 << endl;
  return 0;
}
