#include <bits/stdc++.h>
using namespace std;
bool possible(string name1, string name2) {
  queue<char> str;
  for (long long int i = 0; i < name2.length(); i++) str.push(name2[i]);
  for (long long int i = 0; i < name1.length(); i++) {
    if (!str.empty() && name1[i] == str.front()) str.pop();
  }
  if (str.empty()) return true;
  return false;
}
bool func(string name1, string name2, long long int *a, long long int mid) {
  for (int i = 0; i < mid; i++) name1[a[i] - 1] = '0';
  return possible(name1, name2);
}
int main() {
  string name1;
  string name2;
  cin >> name1 >> name2;
  long long int a[name1.size()];
  for (long long int i = 0; i < name1.size(); i++) cin >> a[i];
  ;
  long long int low = 0, high = name1.size();
  long long ans = 0;
  while (high > low) {
    if (high - low == 1) {
      ans = low;
      break;
    }
    long long int mid = (low + high) / 2;
    if (func(name1, name2, a, mid))
      low = mid;
    else
      high = mid;
  }
  cout << ans;
  return 0;
}
