#include <bits/stdc++.h>
using namespace std;
inline int setBit(int N, int pos) { return N = N | (1 << pos); }
inline int resetBit(int N, int pos) { return N = N & ~(1 << pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1 << pos)); }
const int MAX = 200005;
int n, m, arr[MAX];
char from[MAX], to[MAX];
bool visit[MAX];
inline bool check(int x) {
  int i, j;
  memset(visit, false, sizeof(visit));
  for (i = 0; i < x; i++) visit[arr[i]] = true;
  for (i = 0, j = 0; i < n; i++) {
    if (visit[i]) continue;
    if (from[i] == to[j]) {
      j++;
      if (j == m) return true;
    }
  }
  return false;
}
inline int bs() {
  int low = 0, high = n, mid, ret = 0;
  while (low <= high) {
    mid = (low + high) >> 1;
    if (check(mid)) {
      ret = max(ret, mid);
      low = mid + 1;
    } else
      high = mid - 1;
  }
  return ret;
}
int main() {
  int i;
  scanf("%s", from);
  scanf("%s", to);
  n = strlen(from);
  m = strlen(to);
  for (i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    arr[i]--;
  }
  printf("%d\n", bs());
  return 0;
}
