#include <bits/stdc++.h>
using namespace std;
int p[200001];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string a, b;
  cin >> a >> b;
  int len = a.length(), x;
  for (int i = 0; i < len; i++) {
    cin >> x;
    p[x - 1] = i;
  }
  int l = 0, r = len;
  int res = 0;
  while (l <= r) {
    int m = (l + r) / 2;
    int k = 0;
    for (int i = 0; i < len; i++) {
      if (a[i] == b[k] && m <= p[i]) k++;
    }
    if (k == b.length()) {
      l = m + 1;
      res = m;
    } else {
      r = m - 1;
    }
  }
  cout << res << "\n";
}
