#include <bits/stdc++.h>
using namespace std;
string s1, s2;
vector<int> v;
bool findstr(string str) {
  int a = str.length();
  int b = s2.length();
  int i, j;
  for (i = 0, j = 0; i < a && j < b; i++)
    if (str[i] == s2[j]) j++;
  return (j == b);
}
bool check(int x) {
  string str = s1;
  char ch = '-';
  for (int i = 0; i < x; i++) str[v[i]] = ch;
  str.erase(remove(str.begin(), str.end(), ch), str.end());
  return findstr(str);
}
int main() {
  getline(cin, s1);
  getline(cin, s2);
  int len = s1.length();
  v.resize(len);
  for (int i = 0; i < len; i++) {
    scanf("%d", &v[i]);
    v[i]--;
  }
  int l = 0, r = len, mid, best = 0;
  while (l <= r) {
    mid = (l + r) / 2;
    if (check(mid)) {
      best = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  cout << best << endl;
  return 0;
}
