#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int n = s.length(), m = t.length();
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    a[x - 1] = i + 1;
  }
  int sm = 0, la = n;
  while (la - sm > 1) {
    int mi = (la + sm) / 2;
    int j = 0;
    for (int i = 0; i < n; ++i) {
      if (a[i] > mi && s[i] == t[j]) j++;
    }
    if (j == m)
      sm = mi;
    else
      la = mi;
  }
  cout << sm << endl;
  return 0;
}
