#include <bits/stdc++.h>
using namespace std;
string s, t, temp;
bool check(int mid, vector<int>& v) {
  temp = s;
  for (int i = 0; i < mid; i++) {
    temp[v[i]] = '#';
  }
  int x = 0;
  for (int i = 0; i < temp.size(); i++) {
    if (t[x] == temp[i]) {
      x++;
    }
    if (x == t.size()) return true;
  }
  return false;
}
int main() {
  cin >> s >> t;
  vector<int> v;
  for (int i = 0; i < s.size(); i++) {
    int a;
    cin >> a;
    v.push_back(a - 1);
  }
  int low = 0, high = s.size();
  while (high - low > 1) {
    int mid = low + (high - low) / 2;
    if (check(mid, v))
      low = mid;
    else
      high = mid;
  }
  cout << low << endl;
  return 0;
}
