#include <bits/stdc++.h>
using namespace std;
bool check(string temp, string b) {
  int j = 0;
  for (int i = 0; i < temp.size(); i++) {
    if (temp[i] == b[j]) j++;
  }
  return j == b.size();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string a, b;
  cin >> a >> b;
  int n = a.size();
  int c[n];
  for (int i = 0; i < n; i++) cin >> c[i];
  int l = 0, r = n;
  int max1 = 0;
  while (l <= r) {
    int mid = (l + r) / 2;
    string p = a;
    for (int i = 0; i < mid; i++) {
      p[c[i] - 1] = '.';
    }
    string temp = "";
    for (int i = 0; i < n; i++) {
      if (p[i] != '.') temp += p[i];
    }
    if (check(temp, b)) {
      max1 = max(max1, mid);
      l = mid + 1;
    } else
      r = mid - 1;
  }
  cout << max1;
}
