#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  string bs, cs;
  cin >> bs;
  cin >> cs;
  int arr[bs.length()];
  for (int i = 0; i < bs.length(); i++) {
    cin >> arr[i];
  }
  long long lb = 0;
  long long ub = bs.length() - 1;
  long long mid;
  string temp;
  long long ans = 0;
  while (lb <= ub) {
    mid = (lb + ub) >> 1;
    temp = bs;
    for (int i = 0; i <= mid; i++) {
      temp[arr[i] - 1] = '$';
    }
    int k = 0;
    for (int i = 0; i < temp.length(); i++) {
      if (temp[i] != '$') {
        if (temp[i] == cs[k]) {
          k++;
        }
      }
    }
    if (k == cs.length()) {
      ans = max(mid + 1, ans);
      lb = mid + 1;
    } else {
      ub = mid - 1;
    }
  }
  cout << ans << '\n';
  return 0;
}
