#include <bits/stdc++.h>
using namespace std;
int u[1000001];
string s, t;
bool check(int x) {
  int cur = 0;
  for (int i = 0; i < s.size(); i++) {
    if (u[i] <= x) continue;
    if (s[i] == t[cur]) {
      cur++;
    }
  }
  if (cur == t.size()) {
    return 1;
  } else
    return 0;
}
int main() {
  cin >> s >> t;
  for (int i = 1; i <= s.size(); i++) {
    int x;
    cin >> x;
    u[x - 1] = i;
  }
  int l = 0;
  int r = s.size();
  int ans = -1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (check(mid)) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  cout << ans;
  return 0;
}
