#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  string a, b;
  cin >> a;
  cin >> b;
  long long n1 = b.length();
  n = a.length();
  vector<long long> v(n);
  long long tp;
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &tp);
    v[tp - 1] = i;
  }
  long long l = 1, r = n;
  long long ans = 0;
  while (l <= r) {
    long long m = (l + r) / 2;
    long long j = 0;
    for (long long i = 0; i < n; i++) {
      if (a[i] == b[j] && v[i] >= m) j++;
      if (j == n1) break;
    }
    if (j == n1) {
      if (ans < m) ans = m - 1;
      l = m + 1;
    } else
      r = m - 1;
  }
  printf("%lld\n", ans);
  return 0;
}
