#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 7;
const long long maxs = 2e6 + 5;
long long root[maxs];
inline long long add(long long a, long long b) {
  long long c = ((a % mod) + (b % mod)) % mod;
  return c;
}
inline long long mult(long long a, long long b) {
  long long c = ((a % mod) * (b % mod)) % mod;
  return c;
}
class cmp {
  bool operator()(const long long &a, const long long &b) { return a < b; }
};
void init() { iota(root, root + maxs, 0); }
long long find(long long u) {
  long long f;
  if (root[u] == u)
    return u;
  else {
    long long f = find(root[u]);
    root[u] = f;
    return f;
  }
}
void Union(long long x, long long y) {
  long long u = find(x);
  long long v = find(y);
  root[v] = u;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
void update(vector<long long> &BIT, long long ind, long long val) {
  while (ind < BIT.size()) {
    BIT[ind] += val;
    ind += (ind & (-ind));
  }
}
long long query(vector<long long> &BIT, long long ind) {
  long long sum = 0;
  while (ind > 0) {
    sum += BIT[ind];
    ind -= (ind & (-ind));
  }
  return sum;
}
bool solve(vector<long long> &arr, string &str, string &res, long long ind) {
  set<long long> s;
  for (long long i = 0; i <= ind; i++) s.insert(arr[i]);
  long long l = 0, r = 0, n = str.size(), m = res.size();
  while (l < n && r < m) {
    if (str[l] == res[r] && !s.count(l)) {
      r++;
    }
    l++;
  }
  return r >= m;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t, n, i, k, y, x, j, m, w;
  string str, res;
  cin >> str >> res;
  n = str.size();
  vector<long long> arr(n);
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    arr[i]--;
  }
  long long l = 0, r = n - 1;
  while (l + 1 < r) {
    long long mid = l + (r - l) / 2;
    if (solve(arr, str, res, mid)) {
      l = mid;
    } else {
      r = mid;
    }
  }
  if (solve(arr, str, res, r))
    cout << r + 1;
  else if (solve(arr, str, res, l)) {
    cout << l + 1;
  } else
    cout << 0;
  return 0;
}
