#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  string t;
  cin >> t;
  int val[200001];
  int Ssize = s.size();
  int Tsize = t.size();
  for (int i = 0; i < Ssize; ++i) {
    int num;
    cin >> num;
    val[num - 1] = i;
  }
  int count = 0, r = Ssize;
  while (r - count > 1) {
    int x = (r + count) / 2;
    int j = 0;
    for (int i = 0; i < Ssize; ++i) {
      if (s[i] == t[j] && val[i] >= x) {
        j++;
      }
    }
    if (j == Tsize) {
      count = x;
    } else {
      r = x;
    }
  }
  cout << count << endl;
}
