#include <bits/stdc++.h>
using namespace std;
long long a[200001];
string t, p;
bool solve(long long x) {
  long long j = 0;
  for (long long i = 0; i < t.size(); i++)
    if (t[i] == p[j] && a[i + 1] > x) {
      j++;
      if (j == p.size()) return true;
    }
  return false;
}
int main() {
  cin >> t >> p;
  long long i, x;
  for (i = 0; i < t.size(); i++) {
    cin >> x;
    a[x] = i;
  }
  long long lo = 0;
  long long hi = t.size();
  while (lo <= hi) {
    long long mid = (hi + lo) / 2;
    if (solve(mid))
      lo = mid + 1;
    else
      hi = mid - 1;
  }
  cout << ++hi << endl;
}
