#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
int a[N];
int n, ans = 0;
string p, k;
bool check(int mid) {
  vector<int> vis(n + 1, 0);
  for (int i = 1; i <= mid; ++i) vis[a[i] - 1] = 1;
  string s = "";
  for (int i = 0; i < n; ++i) {
    if (!vis[i]) s += p[i];
  }
  int cnt = 0;
  for (int i = 0, j = 0; i < s.size() && j < k.size();) {
    if (s[i] == k[j])
      i++, j++, cnt++;
    else
      i++;
  }
  if (cnt == k.size()) return true;
  return false;
}
void go(int l, int r) {
  while (l <= r) {
    int mid = l + (r - l) / 2;
    if (check(mid))
      l = mid + 1, ans = mid;
    else
      r = mid - 1;
  }
  cout << ans << "\n";
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> p >> k;
  n = p.size();
  for (int i = 1; i <= n; ++i) cin >> a[i];
  go(1, n);
  return 0;
}
