#include <bits/stdc++.h>
using namespace std;
struct hash_pair {
  template <class T1, class T2>
  size_t operator()(const pair<T1, T2>& p) const {
    auto hash1 = hash<T1>{}(p.first);
    auto hash2 = hash<T2>{}(p.second);
    return hash1 ^ hash2;
  }
};
long long power(long long a, long long n, long long p) {
  if (n == 0) {
    return 1;
  } else if (n % 2 == 0) {
    long long ans = power(a, n / 2, p);
    return (ans * ans) % p;
  } else {
    long long ans = power(a, n - 1, p);
    return (ans * a) % p;
  }
}
long long inverse(long long a, long long p) { return power(a, p - 2, p); }
void solve() {
  string t, p;
  cin >> t >> p;
  int n = t.length(), m = p.length();
  int pos[n];
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    pos[x - 1] = i;
  }
  int l = 0, r = n, mid;
  while (l < r - 1) {
    mid = (l + r) / 2;
    int j = 0;
    for (int i = 0; i < n && j < m; i++) {
      if (pos[i] >= mid && t[i] == p[j]) {
        j++;
      }
    }
    if (j < m) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << l << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
}
