#include <bits/stdc++.h>
using namespace std;
int a[200005][30];
int b[30];
vector<string> vec;
int chk(string s1, string s2) {
  int l1 = s1.length();
  int l2 = s2.length();
  int i = 0, j = 0;
  while (1) {
    if (j == l2) return 1;
    if (i == l1) return 0;
    if (s1[i] == s2[j]) j += 1;
    i += 1;
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  string s1, s2;
  cin >> s1 >> s2;
  s1.push_back('$');
  int l1, l2;
  l1 = s1.length();
  l2 = s2.length();
  int l = 0;
  int r = l1 - 2, mid;
  int iter = 30;
  int arr[200005];
  arr[0] = l1;
  for (int i = 1; i < l1; i++) cin >> arr[i];
  while (iter--) {
    mid = (r - l) / 2 + l;
    string st1 = s1;
    string st2 = s1;
    for (int i = 0; i < mid + 1; i++) st1[arr[i] - 1] = '0';
    for (int i = 0; i < mid + 2; i++) st2[arr[i] - 1] = '0';
    int temp = chk(st1, s2);
    int temp2 = chk(st2, s2);
    if (temp == 1 && temp2 == 0)
      break;
    else if (temp == 0 && temp2 == 0)
      r = mid - 1;
    else
      l = mid + 1;
  }
  cout << mid << "\n";
  return 0;
}
