#include <bits/stdc++.h>
using namespace std;
int ar[200005];
string str, s;
bool isSubSequence(string s1, string s2) {
  int m = s1.size(), n = s2.size(), j = 0;
  for (int i = 0; i < n && j < m; i++) {
    if (s1[j] == s2[i]) j++;
  }
  return (j == m);
}
bool gamesOk(int x) {
  string ss = str;
  for (int i = 0; i < x; i++) ss[ar[i] - 1] = '.';
  return isSubSequence(s, ss);
}
int bs() {
  int lo = 0, hi = str.size();
  while (lo < hi) {
    int mid = (lo + hi + 1) / 2;
    gamesOk(mid) ? lo = mid : hi = mid - 1;
  }
  return lo;
}
int main() {
  cin >> str >> s;
  for (int i = 0; str[i]; i++) cin >> ar[i];
  cout << bs();
  return 0;
}
