#include <bits/stdc++.h>
using namespace std;
long long a[1000000];
int main() {
  string t, p;
  cin >> t >> p;
  long long i, j;
  for (i = 0; i < t.length(); ++i) {
    cin >> j;
    a[j - 1] = i + 1;
  }
  long long beg, end, mid;
  beg = 1;
  end = t.length() - 1;
  while (beg <= end) {
    mid = (beg + end) / 2;
    j = 0;
    for (i = 0; i < t.length(); ++i) {
      if (t[i] == p[j] && a[i] > mid) {
        j++;
      }
    }
    if (j == p.length()) {
      beg = mid + 1;
    } else {
      end = mid - 1;
    }
  }
  cout << end;
}
