#include <bits/stdc++.h>
using namespace std;
string s;
string s1;
long long a[200005];
int b;
long long temp;
int main() {
  cin >> s >> s1;
  int n = s.length();
  int m = s1.length();
  for (int i = 0; i < n; i++) {
    cin >> b;
    a[b - 1] = i;
  }
  long long dau = 0;
  long long cuoi = n;
  while (dau < cuoi) {
    int j = 0;
    temp = (dau + cuoi) / 2;
    for (int i = 0; i < n; i++)
      if (s[i] == s1[j] && a[i] > temp) j++;
    if (j == m)
      dau = temp + 1;
    else
      cuoi = temp;
  }
  cout << dau;
}
