#include <bits/stdc++.h>
using namespace std;
string a, b;
int d[200005];
bool c(int x) {
  int m = 0;
  for (int i = 0; i < a.size(); i++) {
    if (d[i] > x && b[m] == a[i]) m++;
    if (m == b.size()) return 1;
  }
  return 0;
}
int main() {
  cin >> a >> b;
  int n = a.size(), t;
  for (int i = 1; i <= n; i++) scanf("%d", &t), d[t - 1] = i;
  int l = 0, r = n;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (c(m))
      l = m;
    else
      r = m;
  }
  cout << l;
}
