#include <bits/stdc++.h>
using namespace std;
int a[200005], b[200005];
string a1, a2;
bool check(int mid, int cntr) {
  for (int i = 0; i < mid; i++) {
    b[a[i] - 1] = cntr;
  }
  int len = 0, i = 0;
  while (i < a1.size() && len != a2.size()) {
    if (b[i] == cntr) {
      i++;
      continue;
    }
    if (a1[i] == a2[len]) {
      len++;
    }
    i++;
  }
  if (len == a2.size()) {
    return true;
  }
  return false;
}
int fun(int start, int end, int cntr) {
  if (start > end) {
    return 0;
  }
  int mid = (start + end) / 2;
  bool b = check(mid, cntr);
  if (b) {
    return max(mid, fun(mid + 1, end, cntr + 1));
  } else {
    return fun(start, mid - 1, cntr + 1);
  }
}
int main() {
  cin >> a1 >> a2;
  for (int i = 0; i < a1.size(); i++) {
    cin >> a[i];
  }
  cout << fun(0, a1.size(), 1) << endl;
  return 0;
}
